Skip to content

Commit

Permalink
aws-dump: Added ec2:nat-gateways
Browse files Browse the repository at this point in the history
  • Loading branch information
hamstah committed Jul 25, 2019
1 parent acad27c commit dbcb6ae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
15 changes: 8 additions & 7 deletions aws/dump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ Dump AWS resources
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--assume-role-arn=ASSUME-ROLE-ARN
--assume-role-arn=ASSUME-ROLE-ARN
Role to assume
--assume-role-external-id=ASSUME-ROLE-EXTERNAL-ID
--assume-role-external-id=ASSUME-ROLE-EXTERNAL-ID
External ID of the role to assume
--assume-role-session-name=ASSUME-ROLE-SESSION-NAME
--assume-role-session-name=ASSUME-ROLE-SESSION-NAME
Role session name
--region=REGION AWS Region
--mfa-serial-number=MFA-SERIAL-NUMBER
--mfa-serial-number=MFA-SERIAL-NUMBER
MFA Serial Number
--mfa-token-code=MFA-TOKEN-CODE
--mfa-token-code=MFA-TOKEN-CODE
MFA Token Code
-v, --version Display the version
-c, --accounts-config=ACCOUNTS-CONFIG
-c, --accounts-config=ACCOUNTS-CONFIG
Configuration file with the accounts to list resources for.
-t, --terraform-backends-config=TERRAFORM-BACKENDS-CONFIG
-t, --terraform-backends-config=TERRAFORM-BACKENDS-CONFIG
Configuration file with the terraform backends to compare with.
-o, --output=OUTPUT Filename to store the results in.
--only-unmanaged Only return resources not managed by terraform.
Expand All @@ -36,6 +36,7 @@ Flags:
* EC2
* VPC
* Security Groups
* NAT gateways
* IAM (Does not include attachments)
* Users
* Access keys
Expand Down
27 changes: 27 additions & 0 deletions aws/dump/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
"security-groups": EC2ListSecurityGroups,
"images": EC2ListImages,
"instances": EC2ListInstances,
"nat-gateways": EC2ListNATGateways,
},
}
)
Expand Down Expand Up @@ -181,3 +182,29 @@ func EC2ListInstances(session *Session) *ReportResult {

return &ReportResult{instances, err}
}

func EC2ListNATGateways(session *Session) *ReportResult {

client := ec2.New(session.Session, session.Config)

resources := []Resource{}
err := client.DescribeNatGatewaysPages(&ec2.DescribeNatGatewaysInput{},
func(page *ec2.DescribeNatGatewaysOutput, lastPage bool) bool {
for _, natGateway := range page.NatGateways {
resource := Resource{
ID: *natGateway.NatGatewayId,
ARN: "",
AccountID: session.AccountID,
Service: "ec2",
Type: "nat-gateway",
Region: *session.Config.Region,
Metadata: structs.Map(natGateway),
}
resources = append(resources, resource)
}

return true
})

return &ReportResult{resources, err}
}

0 comments on commit dbcb6ae

Please sign in to comment.