From 9c2725e0a5be1375796f9c323392854a71bd25c4 Mon Sep 17 00:00:00 2001 From: Garrett Heel Date: Wed, 16 Sep 2015 09:58:46 -0700 Subject: [PATCH] provider/aws: allow local kinesis --- builtin/providers/aws/config.go | 17 +++++++++-------- builtin/providers/aws/provider.go | 11 +++++++++++ .../docs/providers/aws/index.html.markdown | 2 ++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index f8f443b73..3870391a6 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -44,6 +44,7 @@ type Config struct { ForbiddenAccountIds []interface{} DynamoDBEndpoint string + KinesisEndpoint string } type AWSClient struct { @@ -108,12 +109,6 @@ 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), - } // Some services exist only in us-east-1, e.g. because they manage // resources that can span across multiple regions, or because // signature format v4 requires region to be us-east-1 for global @@ -125,8 +120,11 @@ func (c *Config) Client() (interface{}, error) { MaxRetries: aws.Int(c.MaxRetries), } + awsDynamoDBConfig := *awsConfig + awsDynamoDBConfig.Endpoint = aws.String(c.DynamoDBEndpoint) + log.Println("[INFO] Initializing DynamoDB connection") - client.dynamodbconn = dynamodb.New(awsDynamoDBConfig) + client.dynamodbconn = dynamodb.New(&awsDynamoDBConfig) log.Println("[INFO] Initializing ELB connection") client.elbconn = elb.New(awsConfig) @@ -143,8 +141,11 @@ func (c *Config) Client() (interface{}, error) { log.Println("[INFO] Initializing RDS Connection") client.rdsconn = rds.New(awsConfig) + awsKinesisConfig := *awsConfig + awsKinesisConfig.Endpoint = aws.String(c.KinesisEndpoint) + log.Println("[INFO] Initializing Kinesis Connection") - client.kinesisconn = kinesis.New(awsConfig) + client.kinesisconn = kinesis.New(&awsKinesisConfig) authErr := c.ValidateAccountId(client.iamconn) if authErr != nil { diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index f73580d0f..e05dc93a1 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -153,6 +153,13 @@ func Provider() terraform.ResourceProvider { Default: "", Description: descriptions["dynamodb_endpoint"], }, + + "kinesis_endpoint": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["kinesis_endpoint"], + }, }, ResourcesMap: map[string]*schema.Resource{ @@ -279,6 +286,9 @@ func init() { "dynamodb_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + "It's typically used to connect to dynamodb-local.", + + "kinesis_endpoint": "Use this to override the default endpoint URL constructed from the `region`.\n" + + "It's typically used to connect to kinesalite.", } } @@ -290,6 +300,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { Region: d.Get("region").(string), MaxRetries: d.Get("max_retries").(int), DynamoDBEndpoint: d.Get("dynamodb_endpoint").(string), + KinesisEndpoint: d.Get("kinesis_endpoint").(string), } if v, ok := d.GetOk("allowed_account_ids"); ok { diff --git a/website/source/docs/providers/aws/index.html.markdown b/website/source/docs/providers/aws/index.html.markdown index c6b4cb4fe..05efd5700 100644 --- a/website/source/docs/providers/aws/index.html.markdown +++ b/website/source/docs/providers/aws/index.html.markdown @@ -57,5 +57,7 @@ The following arguments are supported in the `provider` block: * `dynamodb_endpoint` - (Optional) Use this to override the default endpoint URL constructed from the `region`. It's typically used to connect to dynamodb-local. +* `kinesis_endpoint` - (Optional) Use this to override the default endpoint URL constructed from the `region`. It's typically used to connect to kinesalite. + In addition to the above parameters, the `AWS_SESSION_TOKEN` environmental variable can be set to set an MFA token.