Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Rename attachement to attachment #50

Merged
merged 1 commit into from
Nov 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ eu-west-1 - EC2Subnet - 'subnet-154d844e' - would remove
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - would remove
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - would remove
eu-west-1 - IamUserAccessKeys - 'my-user -> ABCDEFGHIJKLMNOPQRST' - would remove
eu-west-1 - IamUserPolicyAttachement - 'my-user -> AdministratorAccess' - would remove
eu-west-1 - IamUserPolicyAttachment - 'my-user -> AdministratorAccess' - would remove
eu-west-1 - IamUser - 'my-user' - would remove
Scan complete: 13 total, 11 nukeable, 2 filtered.

Expand All @@ -118,7 +118,7 @@ accounts:
filters:
IamUser:
- "my-user"
IamUserPolicyAttachement:
IamUserPolicyAttachment:
- "my-user -> AdministratorAccess"
IamUserAccessKeys:
- "my-user -> ABCDEFGHIJKLMNOPQRST"
Expand All @@ -143,7 +143,7 @@ eu-west-1 - EC2Subnet - 'subnet-154d844e' - would remove
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - would remove
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - would remove
eu-west-1 - IamUserAccessKeys - 'my-user -> ABCDEFGHIJKLMNOPQRST' - filtered by config
eu-west-1 - IamUserPolicyAttachement - 'my-user -> AdministratorAccess' - filtered by config
eu-west-1 - IamUserPolicyAttachment - 'my-user -> AdministratorAccess' - filtered by config
eu-west-1 - IamUser - 'my-user' - filtered by config
Scan complete: 13 total, 8 nukeable, 5 filtered.

Expand Down
2 changes: 1 addition & 1 deletion cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestLoadExampleConfig(t *testing.T) {
"IamRole": []string{
"uber.admin",
},
"IamRolePolicyAttachement": []string{
"IamRolePolicyAttachment": []string{
"uber.admin -> AdministratorAccess",
},
},
Expand Down
2 changes: 1 addition & 1 deletion config/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ accounts:
filters:
IamRole:
- "uber.admin"
IamRolePolicyAttachement:
IamRolePolicyAttachment:
- "uber.admin -> AdministratorAccess"
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
)

type EC2InternetGatewayAttachement struct {
type EC2InternetGatewayAttachment struct {
svc *ec2.EC2
vpcId *string
igwId *string
}

func (n *EC2Nuke) ListInternetGatewayAttachements() ([]Resource, error) {
func (n *EC2Nuke) ListInternetGatewayAttachments() ([]Resource, error) {
resp, err := n.Service.DescribeVpcs(nil)
if err != nil {
return nil, err
Expand All @@ -36,7 +36,7 @@ func (n *EC2Nuke) ListInternetGatewayAttachements() ([]Resource, error) {
}

for _, out := range resp.InternetGateways {
resources = append(resources, &EC2InternetGatewayAttachement{
resources = append(resources, &EC2InternetGatewayAttachment{
svc: n.Service,
vpcId: vpc.VpcId,
igwId: out.InternetGatewayId,
Expand All @@ -47,7 +47,7 @@ func (n *EC2Nuke) ListInternetGatewayAttachements() ([]Resource, error) {
return resources, nil
}

func (e *EC2InternetGatewayAttachement) Remove() error {
func (e *EC2InternetGatewayAttachment) Remove() error {
params := &ec2.DetachInternetGatewayInput{
VpcId: e.vpcId,
InternetGatewayId: e.igwId,
Expand All @@ -61,6 +61,6 @@ func (e *EC2InternetGatewayAttachement) Remove() error {
return nil
}

func (e *EC2InternetGatewayAttachement) String() string {
func (e *EC2InternetGatewayAttachment) String() string {
return fmt.Sprintf("%s -> %s", *e.igwId, *e.vpcId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
)

type EC2VpnGatewayAttachement struct {
type EC2VpnGatewayAttachment struct {
svc *ec2.EC2
vpcId string
vpnId string
state string
}

func (n *EC2Nuke) ListVpnGatewayAttachements() ([]Resource, error) {
func (n *EC2Nuke) ListVpnGatewayAttachments() ([]Resource, error) {

resp, err := n.Service.DescribeVpnGateways(nil)
if err != nil {
Expand All @@ -24,7 +24,7 @@ func (n *EC2Nuke) ListVpnGatewayAttachements() ([]Resource, error) {

for _, vgw := range resp.VpnGateways {
for _, att := range vgw.VpcAttachments {
resources = append(resources, &EC2VpnGatewayAttachement{
resources = append(resources, &EC2VpnGatewayAttachment{
svc: n.Service,
vpcId: *att.VpcId,
vpnId: *vgw.VpnGatewayId,
Expand All @@ -36,14 +36,14 @@ func (n *EC2Nuke) ListVpnGatewayAttachements() ([]Resource, error) {
return resources, nil
}

func (i *EC2VpnGatewayAttachement) Filter() error {
func (i *EC2VpnGatewayAttachment) Filter() error {
if i.state == "detached" {
return fmt.Errorf("already detached")
}
return nil
}

func (e *EC2VpnGatewayAttachement) Remove() error {
func (e *EC2VpnGatewayAttachment) Remove() error {
params := &ec2.DetachVpnGatewayInput{
VpcId: &e.vpcId,
VpnGatewayId: &e.vpnId,
Expand All @@ -57,6 +57,6 @@ func (e *EC2VpnGatewayAttachement) Remove() error {
return nil
}

func (e *EC2VpnGatewayAttachement) String() string {
func (e *EC2VpnGatewayAttachment) String() string {
return fmt.Sprintf("%s -> %s", e.vpnId, e.vpcId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
)

type IamGroupPolicyAttachement struct {
type IamGroupPolicyAttachment struct {
svc *iam.IAM
policyArn string
policyName string
roleName string
}

func (n *IamNuke) ListGroupPolicyAttachements() ([]Resource, error) {
func (n *IamNuke) ListGroupPolicyAttachments() ([]Resource, error) {
resp, err := n.Service.ListGroups(nil)
if err != nil {
return nil, err
Expand All @@ -30,7 +30,7 @@ func (n *IamNuke) ListGroupPolicyAttachements() ([]Resource, error) {
}

for _, pol := range resp.AttachedPolicies {
resources = append(resources, &IamGroupPolicyAttachement{
resources = append(resources, &IamGroupPolicyAttachment{
svc: n.Service,
policyArn: *pol.PolicyArn,
policyName: *pol.PolicyName,
Expand All @@ -42,7 +42,7 @@ func (n *IamNuke) ListGroupPolicyAttachements() ([]Resource, error) {
return resources, nil
}

func (e *IamGroupPolicyAttachement) Remove() error {
func (e *IamGroupPolicyAttachment) Remove() error {
_, err := e.svc.DetachGroupPolicy(
&iam.DetachGroupPolicyInput{
PolicyArn: &e.policyArn,
Expand All @@ -55,6 +55,6 @@ func (e *IamGroupPolicyAttachement) Remove() error {
return nil
}

func (e *IamGroupPolicyAttachement) String() string {
func (e *IamGroupPolicyAttachment) String() string {
return fmt.Sprintf("%s -> %s", e.roleName, e.policyName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
)

type IamUserGroupAttachement struct {
type IamUserGroupAttachment struct {
svc *iam.IAM
groupName string
userName string
}

func (n *IamNuke) ListUserGroupAttachements() ([]Resource, error) {
func (n *IamNuke) ListUserGroupAttachments() ([]Resource, error) {
resp, err := n.Service.ListUsers(nil)
if err != nil {
return nil, err
Expand All @@ -29,7 +29,7 @@ func (n *IamNuke) ListUserGroupAttachements() ([]Resource, error) {
}

for _, grp := range resp.Groups {
resources = append(resources, &IamUserGroupAttachement{
resources = append(resources, &IamUserGroupAttachment{
svc: n.Service,
groupName: *grp.GroupName,
userName: *role.UserName,
Expand All @@ -40,7 +40,7 @@ func (n *IamNuke) ListUserGroupAttachements() ([]Resource, error) {
return resources, nil
}

func (e *IamUserGroupAttachement) Remove() error {
func (e *IamUserGroupAttachment) Remove() error {
_, err := e.svc.RemoveUserFromGroup(
&iam.RemoveUserFromGroupInput{
GroupName: &e.groupName,
Expand All @@ -53,6 +53,6 @@ func (e *IamUserGroupAttachement) Remove() error {
return nil
}

func (e *IamUserGroupAttachement) String() string {
func (e *IamUserGroupAttachment) String() string {
return fmt.Sprintf("%s -> %s", e.userName, e.groupName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
)

type IamRolePolicyAttachement struct {
type IamRolePolicyAttachment struct {
svc *iam.IAM
policyArn string
policyName string
roleName string
}

func (n *IamNuke) ListRolePolicyAttachements() ([]Resource, error) {
func (n *IamNuke) ListRolePolicyAttachments() ([]Resource, error) {
resp, err := n.Service.ListRoles(nil)
if err != nil {
return nil, err
Expand All @@ -31,7 +31,7 @@ func (n *IamNuke) ListRolePolicyAttachements() ([]Resource, error) {
}

for _, pol := range resp.AttachedPolicies {
resources = append(resources, &IamRolePolicyAttachement{
resources = append(resources, &IamRolePolicyAttachment{
svc: n.Service,
policyArn: *pol.PolicyArn,
policyName: *pol.PolicyName,
Expand All @@ -43,14 +43,14 @@ func (n *IamNuke) ListRolePolicyAttachements() ([]Resource, error) {
return resources, nil
}

func (e *IamRolePolicyAttachement) Filter() error {
func (e *IamRolePolicyAttachment) Filter() error {
if strings.HasPrefix(e.policyArn, "arn:aws:iam::aws:policy/aws-service-role/") {
return fmt.Errorf("cannot detach from service roles")
}
return nil
}

func (e *IamRolePolicyAttachement) Remove() error {
func (e *IamRolePolicyAttachment) Remove() error {
_, err := e.svc.DetachRolePolicy(
&iam.DetachRolePolicyInput{
PolicyArn: &e.policyArn,
Expand All @@ -63,6 +63,6 @@ func (e *IamRolePolicyAttachement) Remove() error {
return nil
}

func (e *IamRolePolicyAttachement) String() string {
func (e *IamRolePolicyAttachment) String() string {
return fmt.Sprintf("%s -> %s", e.roleName, e.policyName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/aws/aws-sdk-go/service/iam"
)

type IamUserPolicyAttachement struct {
type IamUserPolicyAttachment struct {
svc *iam.IAM
policyArn string
policyName string
roleName string
}

func (n *IamNuke) ListUserPolicyAttachements() ([]Resource, error) {
func (n *IamNuke) ListUserPolicyAttachments() ([]Resource, error) {
resp, err := n.Service.ListUsers(nil)
if err != nil {
return nil, err
Expand All @@ -30,7 +30,7 @@ func (n *IamNuke) ListUserPolicyAttachements() ([]Resource, error) {
}

for _, pol := range resp.AttachedPolicies {
resources = append(resources, &IamUserPolicyAttachement{
resources = append(resources, &IamUserPolicyAttachment{
svc: n.Service,
policyArn: *pol.PolicyArn,
policyName: *pol.PolicyName,
Expand All @@ -42,7 +42,7 @@ func (n *IamNuke) ListUserPolicyAttachements() ([]Resource, error) {
return resources, nil
}

func (e *IamUserPolicyAttachement) Remove() error {
func (e *IamUserPolicyAttachment) Remove() error {
_, err := e.svc.DetachUserPolicy(
&iam.DetachUserPolicyInput{
PolicyArn: &e.policyArn,
Expand All @@ -55,6 +55,6 @@ func (e *IamUserPolicyAttachement) Remove() error {
return nil
}

func (e *IamUserPolicyAttachement) String() string {
func (e *IamUserPolicyAttachment) String() string {
return fmt.Sprintf("%s -> %s", e.roleName, e.policyName)
}
14 changes: 7 additions & 7 deletions resources/listers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetListers(sess *session.Session) []ResourceLister {
ec2.ListCustomerGateways,
ec2.ListDhcpOptions,
ec2.ListInstances,
ec2.ListInternetGatewayAttachements,
ec2.ListInternetGatewayAttachments,
ec2.ListInternetGateways,
ec2.ListKeyPairs,
ec2.ListNatGateways,
Expand All @@ -66,7 +66,7 @@ func GetListers(sess *session.Session) []ResourceLister {
ec2.ListVpcEndpoints,
ec2.ListVpcs,
ec2.ListVpnConnections,
ec2.ListVpnGatewayAttachements,
ec2.ListVpnGatewayAttachments,
ec2.ListVpnGateways,
ecr.ListRepos,
efs.ListFileSystems,
Expand All @@ -76,18 +76,18 @@ func GetListers(sess *session.Session) []ResourceLister {
elb.ListELBs,
elbv2.ListELBs,
elbv2.ListTargetGroups,
iam.ListGroupPolicyAttachements,
iam.ListGroupPolicyAttachments,
iam.ListGroups,
iam.ListInstanceProfileRoles,
iam.ListInstanceProfiles,
iam.ListPolicies,
iam.ListRolePolicyAttachements,
iam.ListRolePolicyAttachments,
iam.ListRoles,
iam.ListServerCertificates,
iam.ListUserAccessKeys,
iam.ListUserGroupAttachements,
iam.ListUserGroupAttachements,
iam.ListUserPolicyAttachements,
iam.ListUserGroupAttachments,
iam.ListUserGroupAttachments,
iam.ListUserPolicyAttachments,
iam.ListUsers,
kms.ListAliases,
kms.ListKeys,
Expand Down