Skip to content

Commit

Permalink
Merge pull request #3255 from Runscope/local-kinesis
Browse files Browse the repository at this point in the history
provider/aws: allow local kinesis
  • Loading branch information
catsby committed Oct 29, 2015
2 parents 8063168 + 9c2725e commit cb2ecf5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
17 changes: 9 additions & 8 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
ForbiddenAccountIds []interface{}

DynamoDBEndpoint string
KinesisEndpoint string
}

type AWSClient struct {
Expand Down Expand Up @@ -116,12 +117,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
Expand All @@ -134,8 +129,11 @@ func (c *Config) Client() (interface{}, error) {
HTTPClient: cleanhttp.DefaultClient(),
}

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)
Expand All @@ -152,8 +150,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 {
Expand Down
11 changes: 11 additions & 0 deletions builtin/providers/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -283,6 +290,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.",
}
}

Expand All @@ -294,6 +304,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 {
Expand Down
2 changes: 2 additions & 0 deletions website/source/docs/providers/aws/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit cb2ecf5

Please sign in to comment.