mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #2825 from phstc/dynamodb-local
provider/aws: Allow to change the DynamoDB Endpoint
This commit is contained in:
commit
649e2ab572
@ -36,6 +36,8 @@ type Config struct {
|
||||
|
||||
AllowedAccountIds []interface{}
|
||||
ForbiddenAccountIds []interface{}
|
||||
|
||||
DynamoDBEndpoint string
|
||||
}
|
||||
|
||||
type AWSClient struct {
|
||||
@ -57,7 +59,7 @@ type AWSClient struct {
|
||||
lambdaconn *lambda.Lambda
|
||||
}
|
||||
|
||||
// Client configures and returns a fully initailized AWSClient
|
||||
// Client configures and returns a fully initialized AWSClient
|
||||
func (c *Config) Client() (interface{}, error) {
|
||||
var client AWSClient
|
||||
|
||||
@ -94,8 +96,15 @@ func (c *Config) Client() (interface{}, error) {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
awsDynamoDBConfig := &aws.Config{
|
||||
Credentials: creds,
|
||||
Region: aws.String(c.Region),
|
||||
MaxRetries: aws.Int(c.MaxRetries),
|
||||
Endpoint: aws.String(c.DynamoDBEndpoint),
|
||||
}
|
||||
|
||||
log.Println("[INFO] Initializing DynamoDB connection")
|
||||
client.dynamodbconn = dynamodb.New(awsConfig)
|
||||
client.dynamodbconn = dynamodb.New(awsDynamoDBConfig)
|
||||
|
||||
log.Println("[INFO] Initializing ELB connection")
|
||||
client.elbconn = elb.New(awsConfig)
|
||||
|
@ -145,6 +145,13 @@ func Provider() terraform.ResourceProvider {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
},
|
||||
|
||||
"dynamodb_endpoint": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Description: descriptions["dynamodb_endpoint"],
|
||||
},
|
||||
},
|
||||
|
||||
ResourcesMap: map[string]*schema.Resource{
|
||||
@ -242,16 +249,20 @@ func init() {
|
||||
"max_retries": "The maximum number of times an AWS API request is\n" +
|
||||
"being executed. If the API request still fails, an error is\n" +
|
||||
"thrown.",
|
||||
|
||||
"dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" +
|
||||
"It's typically used to connect to dynamodb-local.",
|
||||
}
|
||||
}
|
||||
|
||||
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||
config := Config{
|
||||
AccessKey: d.Get("access_key").(string),
|
||||
SecretKey: d.Get("secret_key").(string),
|
||||
Token: d.Get("token").(string),
|
||||
Region: d.Get("region").(string),
|
||||
MaxRetries: d.Get("max_retries").(int),
|
||||
AccessKey: d.Get("access_key").(string),
|
||||
SecretKey: d.Get("secret_key").(string),
|
||||
Token: d.Get("token").(string),
|
||||
Region: d.Get("region").(string),
|
||||
MaxRetries: d.Get("max_retries").(int),
|
||||
DynamoDBEndpoint: d.Get("dynamodb_endpoint").(string),
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("allowed_account_ids"); ok {
|
||||
|
@ -55,5 +55,7 @@ The following arguments are supported in the `provider` block:
|
||||
to prevent you mistakenly using a wrong one (and end up destroying live environment).
|
||||
Conflicts with `allowed_account_ids`.
|
||||
|
||||
* `dynamodb_endpoint` - (Optional) Use this to override the default endpoint URL constructed from the `region`. It's typically used to connect to dynamodb-local.
|
||||
|
||||
In addition to the above parameters, the `AWS_SECURITY_TOKEN` environmental
|
||||
variable can be set to set an MFA token.
|
||||
|
Loading…
Reference in New Issue
Block a user