Skip to content

Commit

Permalink
migrate: aws v2 - vpc lattice
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 committed Oct 30, 2024
1 parent ab10ec7 commit 101a2e6
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion aws/resources/ec2_dhcp_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (v *EC2DhcpOption) disAssociatedAttachedVpcs(identifier *string) error {
logging.Debugf("[disAssociatedAttachedVpcs] detaching the dhcp option %s from %v", awsgo.StringValue(identifier), awsgo.StringValue(option.VpcId))

_, err := v.Client.AssociateDhcpOptionsWithContext(v.Context, &ec2.AssociateDhcpOptionsInput{
VpcId: option.VpcId,
VpcId: option.VpcId,
DhcpOptionsId: awsgo.String("default"), // The ID of the DHCP options set, or default to associate no DHCP options with the VPC.
})
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions aws/resources/ec2_dhcp_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

type mockedEC2DhcpOption struct {
ec2iface.EC2API
DescribeDhcpOptionsOutput ec2.DescribeDhcpOptionsOutput
DeleteDhcpOptionsOutput ec2.DeleteDhcpOptionsOutput
DescribeVpcsOutput ec2.DescribeVpcsOutput
AssociateDhcpOptionsOutput ec2.AssociateDhcpOptionsOutput
DescribeDhcpOptionsOutput ec2.DescribeDhcpOptionsOutput
DeleteDhcpOptionsOutput ec2.DeleteDhcpOptionsOutput
DescribeVpcsOutput ec2.DescribeVpcsOutput
AssociateDhcpOptionsOutput ec2.AssociateDhcpOptionsOutput
}

func (m mockedEC2DhcpOption) DescribeDhcpOptionsPagesWithContext(_ awsgo.Context, _ *ec2.DescribeDhcpOptionsInput, fn func(*ec2.DescribeDhcpOptionsOutput, bool) bool, _ ...request.Option) error {
Expand All @@ -36,7 +36,7 @@ func (m mockedEC2DhcpOption) DeleteDhcpOptionsWithContext(_ awsgo.Context, _ *ec
func (m mockedEC2DhcpOption) DescribeVpcsWithContext(awsgo.Context, *ec2.DescribeVpcsInput, ...request.Option) (*ec2.DescribeVpcsOutput, error) {
return &m.DescribeVpcsOutput, nil
}
func (m mockedEC2DhcpOption) AssociateDhcpOptionsWithContext(awsgo.Context, *ec2.AssociateDhcpOptionsInput, ...request.Option) (*ec2.AssociateDhcpOptionsOutput, error){
func (m mockedEC2DhcpOption) AssociateDhcpOptionsWithContext(awsgo.Context, *ec2.AssociateDhcpOptionsInput, ...request.Option) (*ec2.AssociateDhcpOptionsOutput, error) {
return &m.AssociateDhcpOptionsOutput, nil
}

Expand Down
6 changes: 3 additions & 3 deletions aws/resources/ec2_dhcp_option_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type DHCPOption struct {

type EC2DhcpOption struct {
BaseAwsResource
Client ec2iface.EC2API
Region string
VPCIds []string
Client ec2iface.EC2API
Region string
VPCIds []string
DhcpOptions map[string]DHCPOption
}

Expand Down
2 changes: 1 addition & 1 deletion aws/resources/eventbridge_schedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type EventBridgeScheduleAPI interface {

type EventBridgeSchedule struct {
BaseAwsResource
Client EventBridgeScheduleAPI
Client EventBridgeScheduleAPI
Region string
Schedules []string
}
Expand Down
12 changes: 6 additions & 6 deletions aws/resources/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func (iu *IAMUsers) getAll(c context.Context, configObj config.Config) ([]*strin
err := iu.Client.ListUsersPagesWithContext(iu.Context, input, func(page *iam.ListUsersOutput, lastPage bool) bool {
for _, user := range page.Users {

// Note :
// IAM resource-listing operations return a subset of the available attributes for the resource.
// Note :
// IAM resource-listing operations return a subset of the available attributes for the resource.
// This operation does not return the following attributes, even though they are an attribute of the returned object:
// PermissionsBoundary
// Tags
// Referene : https://docs.aws.amazon.com/cli/latest/reference/iam/list-users.html
// Tags
// Referene : https://docs.aws.amazon.com/cli/latest/reference/iam/list-users.html

var tags []*iam.Tag
iu.Client.ListUserTagsPagesWithContext(iu.Context,&iam.ListUserTagsInput{
iu.Client.ListUserTagsPagesWithContext(iu.Context, &iam.ListUserTagsInput{
UserName: user.UserName,
}, func(page *iam.ListUserTagsOutput, lastPage bool) bool {
tags = append(tags, page.Tags...)
Expand Down
16 changes: 8 additions & 8 deletions aws/resources/route53_hostedzone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func TestR53HostedZone_GetAll(t *testing.T) {
testName1 := "Test name 01"
testName2 := "Test name 02"
rc := Route53HostedZone{
HostedZonesDomains : map[string]*route53.HostedZone{
testId1 : &route53.HostedZone{
Name : awsgo.String(testName1),
HostedZonesDomains: map[string]*route53.HostedZone{
testId1: &route53.HostedZone{
Name: awsgo.String(testName1),
},
testId2 : &route53.HostedZone{
Name : awsgo.String(testName2),
testId2: &route53.HostedZone{
Name: awsgo.String(testName2),
},
},
Client: mockedR53HostedZone{
Expand Down Expand Up @@ -111,9 +111,9 @@ func TestR53HostedZone_Nuke(t *testing.T) {
t.Parallel()

rc := Route53HostedZone{
HostedZonesDomains : map[string]*route53.HostedZone{
"collection-id-01" : &route53.HostedZone{
Name : awsgo.String("domain.com"),
HostedZonesDomains: map[string]*route53.HostedZone{
"collection-id-01": &route53.HostedZone{
Name: awsgo.String("domain.com"),
},
},
Client: mockedR53HostedZone{
Expand Down
8 changes: 4 additions & 4 deletions aws/resources/route53_hostedzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
// Route53HostedZone - represents all Route53HostedZone
type Route53HostedZone struct {
BaseAwsResource
Client route53iface.Route53API
Region string
Ids []string
Client route53iface.Route53API
Region string
Ids []string
HostedZonesDomains map[string]*route53.HostedZone
}

func (r *Route53HostedZone) Init(session *session.Session) {
r.Client = route53.New(session)
r.HostedZonesDomains = make(map[string]*route53.HostedZone,0)
r.HostedZonesDomains = make(map[string]*route53.HostedZone, 0)
}

// ResourceName - the simple name of the aws resource
Expand Down
6 changes: 3 additions & 3 deletions aws/resources/security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ func TestSecurityGroup_GetAll(t *testing.T) {
expected []string
}{
"emptyFilter": {
ctx:ctx,
ctx: ctx,
configObj: config.EC2ResourceType{},
expected: []string{testId1, testId2},
},
"nameExclusionFilter": {
ctx:ctx,
ctx: ctx,
configObj: config.EC2ResourceType{
ResourceType: config.ResourceType{
ExcludeRule: config.FilterRule{
Expand All @@ -115,7 +115,7 @@ func TestSecurityGroup_GetAll(t *testing.T) {
expected: []string{testId2},
},
"timeAfterExclusionFilter": {
ctx:ctx,
ctx: ctx,
configObj: config.EC2ResourceType{
ResourceType: config.ResourceType{
ExcludeRule: config.FilterRule{
Expand Down
6 changes: 3 additions & 3 deletions aws/resources/ses_email_receiving_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

type mockedSesReceiptRule struct {
sesiface.SESAPI
DeleteReceiptRuleSetOutput ses.DeleteReceiptRuleSetOutput
ListReceiptRuleSetsOutput ses.ListReceiptRuleSetsOutput
DescribeActiveReceiptRuleSetOutput ses.DescribeActiveReceiptRuleSetOutput
DeleteReceiptRuleSetOutput ses.DeleteReceiptRuleSetOutput
ListReceiptRuleSetsOutput ses.ListReceiptRuleSetsOutput
DescribeActiveReceiptRuleSetOutput ses.DescribeActiveReceiptRuleSetOutput
}

func (m mockedSesReceiptRule) ListReceiptRuleSetsWithContext(_ awsgo.Context, _ *ses.ListReceiptRuleSetsInput, _ ...request.Option) (*ses.ListReceiptRuleSetsOutput, error) {
Expand Down
8 changes: 4 additions & 4 deletions aws/resources/vpc_lattice_service_network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/gruntwork-io/go-commons/errors"
)

type VPCLatticeServiceNetworkAPI interface{
type VPCLatticeServiceNetworkAPI interface {
ListServiceNetworks(ctx context.Context, params *vpclattice.ListServiceNetworksInput, optFns ...func(*vpclattice.Options)) (*vpclattice.ListServiceNetworksOutput, error)
DeleteServiceNetwork(ctx context.Context, params *vpclattice.DeleteServiceNetworkInput, optFns ...func(*vpclattice.Options)) (*vpclattice.DeleteServiceNetworkOutput, error)
ListServiceNetworkServiceAssociations(ctx context.Context, params *vpclattice.ListServiceNetworkServiceAssociationsInput, optFns ...func(*vpclattice.Options)) (*vpclattice.ListServiceNetworkServiceAssociationsOutput, error)
DeleteServiceNetworkServiceAssociation(ctx context.Context, params *vpclattice.DeleteServiceNetworkServiceAssociationInput, optFns ...func(*vpclattice.Options)) (*vpclattice.DeleteServiceNetworkServiceAssociationOutput, error)
DeleteServiceNetwork(ctx context.Context, params *vpclattice.DeleteServiceNetworkInput, optFns ...func(*vpclattice.Options)) (*vpclattice.DeleteServiceNetworkOutput, error)
ListServiceNetworkServiceAssociations(ctx context.Context, params *vpclattice.ListServiceNetworkServiceAssociationsInput, optFns ...func(*vpclattice.Options)) (*vpclattice.ListServiceNetworkServiceAssociationsOutput, error)
DeleteServiceNetworkServiceAssociation(ctx context.Context, params *vpclattice.DeleteServiceNetworkServiceAssociationInput, optFns ...func(*vpclattice.Options)) (*vpclattice.DeleteServiceNetworkServiceAssociationOutput, error)
}

type VPCLatticeServiceNetwork struct {
Expand Down
2 changes: 1 addition & 1 deletion aws/resources/vpc_lattice_target_group_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type VPCLatticeTargetGroup struct {

func (sch *VPCLatticeTargetGroup) InitV2(cfg awsgo.Config) {
sch.Client = vpclattice.NewFromConfig(cfg)
sch.TargetGroups = make(map[string]*types.TargetGroupSummary,0)
sch.TargetGroups = make(map[string]*types.TargetGroupSummary, 0)
}

func (sch *VPCLatticeTargetGroup) IsUsingV2() bool { return true }
Expand Down

0 comments on commit 101a2e6

Please sign in to comment.