Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
Upgrade sdk v0.2.0 protocol v2 (#66)
Browse files Browse the repository at this point in the history
* Upgrade sdk v0.2.0 protocol v2
  • Loading branch information
roneli authored May 17, 2021
1 parent 9bebda7 commit dd5f58f
Show file tree
Hide file tree
Showing 44 changed files with 788 additions and 553 deletions.
5 changes: 3 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

"github.com/hashicorp/go-hclog"

"github.com/aws/aws-sdk-go-v2/service/cloudfront"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -36,7 +38,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/sns"
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
"github.com/hashicorp/go-hclog"
)

// Provider Client passed as meta to all table fetchers
Expand Down Expand Up @@ -110,7 +111,7 @@ type Client struct {
ReportUsers interface{}
}

// This is needed because https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/feature/s3/manager
// S3Manager This is needed because https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/feature/s3/manager
// has different structure then all other services (i.e no service but just a function) and we need
// the ability to mock it.
// Also we need to use s3 manager to be able to query the bucket-region https://github.com/aws/aws-sdk-go-v2/pull/1027#issuecomment-759818990
Expand Down
101 changes: 24 additions & 77 deletions client/config.go
Original file line number Diff line number Diff line change
@@ -1,86 +1,33 @@
package client

// Provider Configuration
type Account struct {
ID string
RoleARN string `yaml:"role_arn"`
ID string `hcl:"label,optional"`
RoleARN string `hcl:"role_arn,optional"`
}

type Config struct {
Regions []string `yaml:"regions"`
Accounts []Account `yaml:"accounts"`
AWSDebug bool `yaml:"aws_debug"`
LogLevel *string `yaml:"log_level"`
MaxRetries int `yaml:"max_retries" default:"5"`
MaxBackoff int `yaml:"max_backoff" default:"30"`
Resources []Resource
Regions []string `hcl:"regions,optional"`
Accounts []Account `hcl:"accounts,block"`
AWSDebug bool `hcl:"aws_debug,optional"`
MaxRetries int `hcl:"max_retries,optional" default:"5"`
MaxBackoff int `hcl:"max_backoff,optional" default:"30"`
}

type Resource struct {
Name string
Other map[string]interface{} `yaml:",inline"`
func (c Config) Example() string {
return `configuration {
// Optional. if you want to assume role to multiple account and fetch data from them
//accounts "<YOUR ID>"{
// Optional. Role ARN we want to assume when accessing this account
// role_arn = <YOUR_ROLE_ARN>
// }
// Optional. by default assumes all regions
// regions = ["us-east-1", "us-west-2"]
// Optional. Enable AWS SDK debug logging.
aws_debug = false
// The maximum number of times that a request will be retried for failures. Defaults to 5 retry attempts.
// max_retries = 5
// The maximum back off delay between attempts. The backoff delays exponentially with a jitter based on the number of attempts. Defaults to 60 seconds.
// max_backoff = 30
}
`
}

const DefaultConfigYaml = `
- name: aws
# accounts: # Optional. if you want to assume role to multiple account and fetch data from them
# - role_arn: <CHANGE_THIS>
# regions: # Optional. if commented out assumes all regions
# - us-east-1
# - us-west-2
# aws_debug: false # Optional. if commented out will enable AWS SDK debug logging.
# max_retries: 5 # Optional. The maximum number of times that a request will be retried for failures. Defaults to 5 retry attempts.
# max_backoff: 30 # Optional. The maximum back off delay between attempts. The backoff delays exponentially with a jitter based on the number of attempts. Defaults to 60 seconds.
resources: # You can comment resources your are not interested in for faster fetching.
- name: autoscaling.launch_configurations
- name: cloudfront.cache_policies
- name: cloudfront.distributions
- name: cloudtrail.trails
- name: cloudwatch.alarms
- name: cloudwatchlogs.filters
- name: directconnect.gateways
- name: directconnect.virtual_gateways
- name: directconnect.virtual_interfaces
- name: ec2.customer_gateways
- name: ec2.ebs_volumes
- name: ec2.flow_logs
- name: ec2.images
- name: ec2.instances
- name: ec2.internet_gateways
- name: ec2.nat_gateways
- name: ec2.network_acls
- name: ec2.route_tables
- name: ec2.security_groups
- name: ec2.subnets
- name: ec2.transit_gateways
- name: ec2.vpc_peering_connections
- name: ec2.vpcs
- name: ec2.vpc_endpoints
- name: ecs.clusters
- name: ecr.repositories
- name: efs.filesystems
- name: eks.clusters
- name: elasticbeanstalk.environments
- name: elbv2.load_balancers
- name: elbv2.target_groups
- name: emr.clusters
- name: fsx.backups
- name: iam.groups
- name: iam.password_policies
- name: iam.policies
- name: iam.roles
- name: iam.users
- name: iam.virtual_mfa_devices
- name: iam.openid_connect_identity_providers
- name: iam.saml_identity_providers
- name: kms.keys
- name: organizations.accounts
- name: rds.certificates
- name: rds.clusters
- name: rds.db_subnet_groups
- name: rds.instances
- name: redshift.clusters
- name: redshift.subnet_groups
- name: s3.buckets
- name: sns.subscriptions
- name: sns.topics`
Loading

0 comments on commit dd5f58f

Please sign in to comment.