Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to aws sdk v.1.2 #29

Merged
merged 9 commits into from
Apr 16, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A list command for AWS resources.
[![Travis](https://img.shields.io/travis/jckuester/awsls/master.svg?style=for-the-badge)](https://travis-ci.org/jckuester/awsls)

awsls supports listing of [over 250 types of resources](#supported-resources)
across 95 different AWS services. The goal is to code-generate a list function for
across 97 different AWS services. The goal is to code-generate a list function for
every AWS resource that is covered by the Terraform AWS Provider (currently over 500). If you want to contribute,
[the generator is here](./gen).

Expand Down Expand Up @@ -96,7 +96,7 @@ The `--all-profiles` flag will use all profiles from `~/.aws/config`, or if `AWS

## Supported resources

Currently, all 271 resource types across 95 services in the table below can be listed with awsls. The `Tags` column shows if a resource
Currently, all 287 resource types across 97 services in the table below can be listed with awsls. The `Tags` column shows if a resource
supports displaying tags, the `Creation Time` column if a resource has a creation timestamp, and the `Owner` column if
resources are pre-filtered belonging to the account owner.

Expand Down Expand Up @@ -147,6 +147,7 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| **cloudwatch** |
| aws_cloudwatch_dashboard | | |
| **cloudwatchevents** |
| aws_cloudwatch_event_archive | | x |
| aws_cloudwatch_event_bus | x | |
| **cloudwatchlogs** |
| aws_cloudwatch_log_destination | | x |
Expand Down Expand Up @@ -208,9 +209,10 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_ebs_snapshot | x | x | x |
| aws_ebs_volume | x | x |
| aws_ec2_capacity_reservation | x | x | x |
| aws_ec2_carrier_gateway | x | | x |
| aws_ec2_client_vpn_endpoint | x | x |
| aws_ec2_fleet | x | x |
| aws_ec2_local_gateway_route_table_vpc_association | x | |
| aws_ec2_local_gateway_route_table_vpc_association | x | | x |
| aws_ec2_managed_prefix_list | x | | x |
| aws_ec2_traffic_mirror_filter | x | |
| aws_ec2_traffic_mirror_session | x | | x |
Expand Down Expand Up @@ -242,6 +244,8 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_vpn_gateway | x | |
| **ecr** |
| aws_ecr_repository | x | |
| **ecrpublic** |
| aws_ecrpublic_repository | | |
| **ecs** |
| aws_ecs_cluster | x | |
| aws_ecs_task_definition | x | |
Expand All @@ -257,15 +261,15 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_elastic_beanstalk_application | x | |
| aws_elastic_beanstalk_application_version | x | |
| aws_elastic_beanstalk_environment | x | |
| **elasticloadbalancing** |
| **elastictranscoder** |
| aws_elastictranscoder_pipeline | | |
| aws_elastictranscoder_preset | | |
| **elb** |
| aws_elb | x | x |
| **elasticloadbalancingv2** |
| **elbv2** |
| aws_alb_target_group | x | |
| aws_lb | x | x |
| aws_lb_target_group | x | |
| **elastictranscoder** |
| aws_elastictranscoder_pipeline | | |
| aws_elastictranscoder_preset | | |
| **emr** |
| aws_emr_security_configuration | | |
| **firehose** |
Expand All @@ -287,6 +291,8 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_glue_dev_endpoint | x | |
| aws_glue_job | x | |
| aws_glue_ml_transform | x | |
| aws_glue_registry | x | x |
| aws_glue_schema | x | x |
| aws_glue_security_configuration | | |
| aws_glue_trigger | x | |
| aws_glue_workflow | x | |
Expand Down Expand Up @@ -329,6 +335,7 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_kms_external_key | x | |
| aws_kms_key | x | |
| **lambda** |
| aws_lambda_code_signing_config | | |
| aws_lambda_event_source_mapping | | |
| aws_lambda_function | x | |
| **lexmodelbuildingservice** |
Expand All @@ -353,6 +360,10 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_mq_configuration | x | |
| **neptune** |
| aws_neptune_event_subscription | x | |
| **networkfirewall** |
| aws_networkfirewall_firewall | x | |
| aws_networkfirewall_firewall_policy | x | |
| aws_networkfirewall_rule_group | x | |
| **opsworks** |
| aws_opsworks_stack | x | |
| aws_opsworks_user_profile | | |
Expand Down Expand Up @@ -383,14 +394,21 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_route53_zone | x | |
| **route53resolver** |
| aws_route53_resolver_endpoint | x | x |
| aws_route53_resolver_rule | x | | x |
| aws_route53_resolver_query_log_config | x | x | x |
| aws_route53_resolver_query_log_config_association | | x |
| aws_route53_resolver_rule | x | x | x |
| aws_route53_resolver_rule_association | | |
| **s3** |
| aws_s3_bucket | x | x |
| **s3outposts** |
| aws_s3outposts_endpoint | | x |
| **sagemaker** |
| aws_sagemaker_app_image_config | | x |
| aws_sagemaker_code_repository | | x |
| aws_sagemaker_endpoint | x | x |
| aws_sagemaker_feature_group | x | x |
| aws_sagemaker_model | x | x |
| aws_sagemaker_model_package_group | x | x |
| **secretsmanager** |
| aws_secretsmanager_secret | x | |
| **securityhub** |
Expand All @@ -411,9 +429,8 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_sfn_activity | x | x |
| aws_sfn_state_machine | x | x |
| **signer** |
| aws_signer_signing_job | | |
| aws_signer_signing_profile | x | |
| **simpledb** |
| aws_simpledb_domain | | |
| **sns** |
| aws_sns_platform_application | | |
| aws_sns_topic | x | |
Expand All @@ -431,6 +448,7 @@ Note: the prefix `aws_` for resource types is now optional. This means, for exam
| aws_ssm_resource_data_sync | | |
| **storagegateway** |
| aws_storagegateway_gateway | x | |
| aws_storagegateway_tape_pool | x | |
| **synthetics** |
| aws_synthetics_canary | x | |
| **transfer** |
Expand Down
23 changes: 7 additions & 16 deletions aws/aws_accessanalyzer_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListAccessanalyzerAnalyzer(client *aws.Client) ([]terraform.Resource, error) {
req := client.Accessanalyzerconn.ListAnalyzersRequest(&accessanalyzer.ListAnalyzersInput{})

func ListAccessanalyzerAnalyzer(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

p := accessanalyzer.NewListAnalyzersPaginator(req)
for p.Next(context.Background()) {
resp := p.CurrentPage()
p := accessanalyzer.NewListAnalyzersPaginator(client.Accessanalyzerconn, &accessanalyzer.ListAnalyzersInput{})
for p.HasMorePages() {
resp, err := p.NextPage(ctx)
if err != nil {
return nil, err
}

for _, r := range resp.Analyzers {

tags := map[string]string{}
for k, v := range r.Tags {
tags[k] = v
}

result = append(result, terraform.Resource{
Type: "aws_accessanalyzer_analyzer",
ID: *r.Name,
Profile: client.Profile,
Region: client.Region,
AccountID: client.AccountID,
Tags: tags,
})
}
}

if err := p.Err(); err != nil {
return nil, err
}

return result, nil
}
17 changes: 7 additions & 10 deletions aws/aws_acm_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListAcmCertificate(client *aws.Client) ([]terraform.Resource, error) {
req := client.Acmconn.ListCertificatesRequest(&acm.ListCertificatesInput{})

func ListAcmCertificate(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

p := acm.NewListCertificatesPaginator(req)
for p.Next(context.Background()) {
resp := p.CurrentPage()
p := acm.NewListCertificatesPaginator(client.Acmconn, &acm.ListCertificatesInput{})
for p.HasMorePages() {
resp, err := p.NextPage(ctx)
if err != nil {
return nil, err
}

for _, r := range resp.CertificateSummaryList {

Expand All @@ -31,9 +32,5 @@ func ListAcmCertificate(client *aws.Client) ([]terraform.Resource, error) {
}
}

if err := p.Err(); err != nil {
return nil, err
}

return result, nil
}
17 changes: 7 additions & 10 deletions aws/aws_alb_target_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListAlbTargetGroup(client *aws.Client) ([]terraform.Resource, error) {
req := client.Elasticloadbalancingv2conn.DescribeTargetGroupsRequest(&elasticloadbalancingv2.DescribeTargetGroupsInput{})

func ListAlbTargetGroup(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

p := elasticloadbalancingv2.NewDescribeTargetGroupsPaginator(req)
for p.Next(context.Background()) {
resp := p.CurrentPage()
p := elasticloadbalancingv2.NewDescribeTargetGroupsPaginator(client.Elasticloadbalancingv2conn, &elasticloadbalancingv2.DescribeTargetGroupsInput{})
for p.HasMorePages() {
resp, err := p.NextPage(ctx)
if err != nil {
return nil, err
}

for _, r := range resp.TargetGroups {

Expand All @@ -31,9 +32,5 @@ func ListAlbTargetGroup(client *aws.Client) ([]terraform.Resource, error) {
}
}

if err := p.Err(); err != nil {
return nil, err
}

return result, nil
}
15 changes: 4 additions & 11 deletions aws/aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListAmi(client *aws.Client) ([]terraform.Resource, error) {
req := client.Ec2conn.DescribeImagesRequest(&ec2.DescribeImagesInput{
Owners: []string{"self"},
})

func ListAmi(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

resp, err := req.Send(context.Background())
resp, err := client.Ec2conn.DescribeImages(ctx, &ec2.DescribeImagesInput{
Owners: []string{"self"},
})
if err != nil {
return nil, err
}
Expand All @@ -29,10 +27,6 @@ func ListAmi(client *aws.Client) ([]terraform.Resource, error) {
if *r.OwnerId != client.AccountID {
continue
}
tags := map[string]string{}
for _, t := range r.Tags {
tags[*t.Key] = *t.Value
}
t, err := time.Parse("2006-01-02T15:04:05.000Z0700", *r.CreationDate)
if err != nil {
return nil, err
Expand All @@ -43,7 +37,6 @@ func ListAmi(client *aws.Client) ([]terraform.Resource, error) {
Profile: client.Profile,
Region: client.Region,
AccountID: client.AccountID,
Tags: tags,
CreatedAt: &t,
})
}
Expand Down
23 changes: 7 additions & 16 deletions aws/aws_api_gateway_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListApiGatewayApiKey(client *aws.Client) ([]terraform.Resource, error) {
req := client.Apigatewayconn.GetApiKeysRequest(&apigateway.GetApiKeysInput{})

func ListApiGatewayApiKey(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

p := apigateway.NewGetApiKeysPaginator(req)
for p.Next(context.Background()) {
resp := p.CurrentPage()
p := apigateway.NewGetApiKeysPaginator(client.Apigatewayconn, &apigateway.GetApiKeysInput{})
for p.HasMorePages() {
resp, err := p.NextPage(ctx)
if err != nil {
return nil, err
}

for _, r := range resp.Items {

tags := map[string]string{}
for k, v := range r.Tags {
tags[k] = v
}

result = append(result, terraform.Resource{
Type: "aws_api_gateway_api_key",
ID: *r.Id,
Profile: client.Profile,
Region: client.Region,
AccountID: client.AccountID,
Tags: tags,
})
}
}

if err := p.Err(); err != nil {
return nil, err
}

return result, nil
}
23 changes: 7 additions & 16 deletions aws/aws_api_gateway_client_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@ import (
"github.com/jckuester/awstools-lib/terraform"
)

func ListApiGatewayClientCertificate(client *aws.Client) ([]terraform.Resource, error) {
req := client.Apigatewayconn.GetClientCertificatesRequest(&apigateway.GetClientCertificatesInput{})

func ListApiGatewayClientCertificate(ctx context.Context, client *aws.Client) ([]terraform.Resource, error) {
var result []terraform.Resource

p := apigateway.NewGetClientCertificatesPaginator(req)
for p.Next(context.Background()) {
resp := p.CurrentPage()
p := apigateway.NewGetClientCertificatesPaginator(client.Apigatewayconn, &apigateway.GetClientCertificatesInput{})
for p.HasMorePages() {
resp, err := p.NextPage(ctx)
if err != nil {
return nil, err
}

for _, r := range resp.Items {

tags := map[string]string{}
for k, v := range r.Tags {
tags[k] = v
}

result = append(result, terraform.Resource{
Type: "aws_api_gateway_client_certificate",
ID: *r.ClientCertificateId,
Profile: client.Profile,
Region: client.Region,
AccountID: client.AccountID,
Tags: tags,
})
}
}

if err := p.Err(); err != nil {
return nil, err
}

return result, nil
}
Loading