Skip to content

Commit

Permalink
Update doc comments for endpoint_url config arg and tidy default se…
Browse files Browse the repository at this point in the history
…ssion config options #1050
  • Loading branch information
cbruno10 committed Jun 3, 2022
1 parent 54741bf commit 60c6929
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 13 additions & 9 deletions aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ func CloudWatchLogsService(ctx context.Context, d *plugin.QueryData) (*cloudwatc

// CloudTrailService returns the service connection for AWS CloudTrail service
func CloudTrailService(ctx context.Context, d *plugin.QueryData, region string) (*cloudtrail.CloudTrail, error) {

if region == "" {
return nil, fmt.Errorf("region must be passed CloudTrailService")
}
Expand Down Expand Up @@ -1984,24 +1983,29 @@ func getSessionWithMaxRetries(ctx context.Context, d *plugin.QueryData, region s
// get aws config info
awsConfig := GetConfig(d.Connection)

// handle custom endpoint url, if any
awsEndpointUrl := os.Getenv("AWS_ENDPOINT_URL")

if awsConfig.EndpointUrl != nil {
awsEndpointUrl = *awsConfig.EndpointUrl
}

// session default configuration
sessionOptions := session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{
Region: &region,
MaxRetries: aws.Int(maxRetries),
Retryer: NewConnectionErrRetryer(maxRetries, minRetryDelay, ctx),
Endpoint: aws.String(awsEndpointUrl),
},
}

// handle custom endpoint URL, if any
var awsEndpointUrl string

awsEndpointUrl = os.Getenv("AWS_ENDPOINT_URL")

if awsConfig.EndpointUrl != nil {
awsEndpointUrl = *awsConfig.EndpointUrl
}

if awsEndpointUrl != "" {
sessionOptions.Config.Endpoint = aws.String(awsEndpointUrl)
}

if awsConfig.Profile != nil {
sessionOptions.Profile = *awsConfig.Profile
}
Expand Down
7 changes: 3 additions & 4 deletions config/aws.spc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ connection "aws" {
# By default, common not found error codes are ignored and will still be ignored even if this argument is not set.
#ignore_error_codes = ["AccessDenied", "AccessDeniedException", "NotAuthorized", "UnauthorizedOperation", "UnrecognizedClientException", "AuthorizationError"]

# Specifies the URL to send the AWS request to. In order to make Steampipe to work with Localstack
# it will be required to provide custom url that Steampipe will use:
# 1. The `AWS_ENDPOINT_URL` environment variable
# 2. The endpoint url specified for the particular connection
# Specify the endpoint URL used when making requests to AWS services.
# If not set, the default AWS generated endpoint will be used.
# Can also be set with the AWS_ENDPOINT_URL environment variable.
#endpoint_url = "http://localhost:4566"
}
6 changes: 6 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ connection "aws" {
# List of additional AWS error codes to ignore for all queries.
# By default, common not found error codes are ignored and will still be ignored even if this argument is not set.
#ignore_error_codes = ["AccessDenied", "AccessDeniedException", "NotAuthorized", "UnauthorizedOperation", "UnrecognizedClientException", "AuthorizationError"]
# Specify the endpoint URL used when making requests to AWS services.
# If not set, the default AWS generated endpoint will be used.
# Can also be set with the AWS_ENDPOINT_URL environment variable.
#endpoint_url = "http://localhost:4566"
}
```

- `access_key` - (Optional) AWS access key ID. Can also be set with the `AWS_ACCESS_KEY_ID` environment variable.
- `endpoint_url` - (Optional) The endpoint URL used when making requests to AWS services. If not set, the default AWS generated endpoint will be used. Can also be set with the `AWS_ENDPOINT_URL` environment variable.
- `ignore_error_codes` - (Optional) List of additional AWS error codes to ignore for all queries. By default, common not found error codes are ignored and will still be ignored even if this argument is not set.
- `max_error_retry_attempts` - (Optional) The maximum number of attempts (including the initial call) Steampipe will make for failing API calls. Can also be set with the `AWS_MAX_ATTEMPTS` environment variable. Defaults to 9 and must be greater than or equal to 1.
- `min_error_retry_delay` - (Optional) The minimum retry delay in milliseconds after which retries will be performed. This delay is also used as a base value when calculating the exponential backoff retry times. Defaults to 25ms and must be greater than or equal to 1ms.
Expand Down

0 comments on commit 60c6929

Please sign in to comment.