Skip to content

Commit

Permalink
Upgrade awsls and terradozer to v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jckuester committed Jun 8, 2020
1 parent 17f4638 commit 1501a9a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.13

require (
github.com/apex/log v1.1.2
github.com/aws/aws-sdk-go v1.30.5
github.com/aws/aws-sdk-go v1.30.12
github.com/fatih/color v1.9.0
github.com/golang/mock v1.4.0
github.com/gruntwork-io/terratest v0.24.2
github.com/jckuester/awsls v0.0.0-20200524112109-93c2a4665746
github.com/jckuester/terradozer v0.0.0-20200523195146-e66de6fa55f3
github.com/jckuester/awsls v0.1.1
github.com/jckuester/terradozer v0.1.1
github.com/onsi/gomega v1.9.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
Expand Down
15 changes: 12 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ github.com/aws/aws-sdk-go v1.23.8/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.29.1/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg=
github.com/aws/aws-sdk-go v1.30.5 h1:i+sSesaMrSxiUt3NJddOApe2mXK+VNBgfcmRTvNFrXM=
github.com/aws/aws-sdk-go v1.30.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.30.12 h1:KrjyosZvkpJjcwMk0RNxMZewQ47v7+ZkbQDXjWsJMs8=
github.com/aws/aws-sdk-go v1.30.12/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go-v2 v0.22.0 h1:mlixfS5HVzn7Sf3KVhjAIM2H3bB7uoTbLCtKHvteUfE=
github.com/aws/aws-sdk-go-v2 v0.22.0/go.mod h1:2LhT7UgHOXK3UXONKI5OMgIyoQL6zTAw/jwIeX6yqzw=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
Expand Down Expand Up @@ -330,8 +331,9 @@ github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE=
github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
github.com/hashicorp/terraform v0.12.24 h1:lTTswsCcmTOhTwuUl2NdjtJBCNdGqZmRGQi0cjFHYOM=
github.com/hashicorp/terraform v0.12.24/go.mod h1:eJcloDEx5ywM4a1tetIuVrlqklM0bUVRYJBYAh4CYzA=
github.com/hashicorp/terraform v0.12.25 h1:4RCbJeJvBTl+t9SDa3xqEU9G9sH5khqjlabr/89bshk=
github.com/hashicorp/terraform v0.12.25/go.mod h1:B9VZ/cn0j1wpi16bdgLBCw5D5wNOqM8DVP0al92nPXc=
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 h1:Pc5TCv9mbxFN6UVX0LH6CpQrdTM5YjbVI2w15237Pjk=
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A=
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg=
Expand All @@ -347,8 +349,13 @@ github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jckuester/awsls v0.0.0-20200524112109-93c2a4665746 h1:CCO3Lc/ofOzEwH5WIZpndhoixKwNQRNVPKczVT4IS9w=
github.com/jckuester/awsls v0.0.0-20200524112109-93c2a4665746/go.mod h1:hbj1nD8zXLBoZffzkV7WXUmMGarGPKkFeke90U9eehs=
github.com/jckuester/terradozer v0.0.0-20200523195146-e66de6fa55f3 h1:uba9ja+voKyereVEuM7YI6kDQO0W1890W+Y5MBWutI8=
github.com/jckuester/awsls v0.1.1 h1:mGiVUZ8b/ZSeweMyxQfBg8Ri28+NabObKuUv6+52lqg=
github.com/jckuester/awsls v0.1.1/go.mod h1:QSYGMRWZLtSibkUbHmjXKov9pogJ8gD2OSFqQanOVHk=
github.com/jckuester/terradozer v0.0.0-20200523195146-e66de6fa55f3/go.mod h1:KYrRcPbIiXgcRp7hG9fOBdAyvDnUx2aA9cjTqvKa4cI=
github.com/jckuester/terradozer v0.1.0 h1:dsZHaY1vH0XNDDIAensa4IkoL7+WKUqDpEu7xl5hg/E=
github.com/jckuester/terradozer v0.1.0/go.mod h1:ZHLoxb3vdsXGCmxeUb7vPy/T6yPzecD0rn1NWdH9aww=
github.com/jckuester/terradozer v0.1.1 h1:ypKZXvnCPAwbWi4am+OvSA6aW/7JxHGiRjpXSI9ZSpg=
github.com/jckuester/terradozer v0.1.1/go.mod h1:ZHLoxb3vdsXGCmxeUb7vPy/T6yPzecD0rn1NWdH9aww=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down Expand Up @@ -615,6 +622,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200109152110-61a87790db17 h1:nVJ3guKA9qdkEQ3TUdXI9QSINo2CUPM/cySEvw2w8I0=
golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func mainExitCode() int {
return 1
}

provider, err := provider.Init("aws", timeoutDuration)
provider, err := provider.Init("aws", "~/.awsweeper", timeoutDuration)
if err != nil {
log.WithError(err).Error("failed to initialize Terraform AWS Providers")
return 1
Expand Down
12 changes: 6 additions & 6 deletions pkg/resource/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func List(filter *Filter, client *AWS, awsClient *awsls.Client,
print(filteredRes, outputType)

for _, r := range filteredRes {
destroyableRes = append(destroyableRes, r.Resource)
destroyableRes = append(destroyableRes, terradozerRes.NewWithState(r.Type, r.ID, provider, r.State()))
}
} else {
resources, err := awsls.ListResourcesByType(awsClient, rType)
Expand Down Expand Up @@ -80,7 +80,7 @@ func List(filter *Filter, client *AWS, awsClient *awsls.Client,
}

for _, r := range filteredRes {
destroyableRes = append(destroyableRes, r.Resource)
destroyableRes = append(destroyableRes, terradozerRes.NewWithState(r.Type, r.ID, provider, r.State()))
}
}
}
Expand All @@ -107,7 +107,7 @@ func getAttachedUserPolicies(users []awsls.Resource, client *AWS,
ID: *attachedPolicy.PolicyArn,
}

r.Resource = terradozerRes.New(r.Type, r.ID, map[string]cty.Value{
r.UpdatableResource = terradozerRes.New(r.Type, r.ID, map[string]cty.Value{
"user": cty.StringVal(user.ID),
"policy_arn": cty.StringVal(*attachedPolicy.PolicyArn),
}, provider)
Expand Down Expand Up @@ -144,7 +144,7 @@ func getInlineUserPolicies(users []awsls.Resource, client *AWS,
ID: user.ID + ":" + *inlinePolicy,
}

r.Resource = terradozerRes.New(r.Type, r.ID, nil, provider)
r.UpdatableResource = terradozerRes.New(r.Type, r.ID, nil, provider)

err = r.UpdateState()
if err != nil {
Expand Down Expand Up @@ -175,7 +175,7 @@ func getPolicyAttachments(policies []awsls.Resource, provider *provider.Terrafor
ID: policy.ID,
}

r.Resource = terradozerRes.New(r.Type, r.ID, map[string]cty.Value{
r.UpdatableResource = terradozerRes.New(r.Type, r.ID, map[string]cty.Value{
"policy_arn": cty.StringVal(arn),
}, provider)

Expand Down Expand Up @@ -211,7 +211,7 @@ func getEfsMountTargets(efsFileSystems []awsls.Resource, client *AWS,
ID: *mountTarget.MountTargetId,
}

r.Resource = terradozerRes.New(r.Type, r.ID, nil, provider)
r.UpdatableResource = terradozerRes.New(r.Type, r.ID, nil, provider)

err = r.UpdateState()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (f Filter) Apply(res []awsls.Resource) []awsls.Resource {
}

func GetTags(r *awsls.Resource) (map[string]string, error) {
if r.Resource == nil {
if r == nil || r.UpdatableResource == nil {
return nil, fmt.Errorf("resource is nil")
}

Expand Down

0 comments on commit 1501a9a

Please sign in to comment.