Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: Allow to change the DynamoDB Endpoint #2825

Merged
merged 5 commits into from
Jul 30, 2015

Conversation

phstc
Copy link

@phstc phstc commented Jul 22, 2015

Hi

This PR allows us to change the DynamoDB Endpoint, which super useful to run "migrations" against dynamodb-local.

With that, we can use the same scripts we use in production (AWS DynamoDB), in development (dynamodb-local).

The way I'm using it:

cd tf/local

ls
table1.tf
table2.tf
config.tf

terraform plan
terraform apply

In the folder local besides the table definitions, I have also a config.tf with:

provider "aws" {
    access_key = "123"
    secret_key = "123"
    region = "us-east-1"
    dynamodb_endpoint = "http://localhost:8000"
}

which changes the DynamoDB Endpoint.

I've intentionally set access and secret to 123, as we don't need those to connect to dynamodb-local.

Any code feedback would be more than appreciated 🍻

Fix #2763.

…B Endpoint for

example to connect to dynamodb-local
@phstc phstc changed the title Allow to change DynamoDB Endpoint Allow to change the DynamoDB Endpoint Jul 22, 2015
Region: c.Region,
MaxRetries: c.MaxRetries,
Endpoint: c.DynamoDBEndpoint,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like this duplication of configs, but we can't set Endpoint for all other connections. I've also tried to copy awsConfig, but go didn't like it:

awsDynamoDBConfig := *awsConfig
awsDynamoDBConfig.Endpoint = c.DynamoDBEndpoint

Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now - the duplication is super local. If we get more duplication here we can investigate cleanup options. 👌

@phstc phstc changed the title Allow to change the DynamoDB Endpoint provider/aws: Allow to change the DynamoDB Endpoint Jul 22, 2015
"dynamodb_endpoint": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "" equivalent to "use upstream default" here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phinze that's correct based on their docs: https://github.com/aws/aws-sdk-go/blob/67dc9f948602be9f85cb640f89b0adec994ccbda/aws/config.go#L49-L55 and I've also confirmed that on my local tests.

But I can remove the Default: "" above and make it more explicit:

awsDynamoDBConfig := &aws.Config{
    Credentials: creds,
    Region:      c.Region,
    MaxRetries:  c.MaxRetries,
}

if c.DynamoDBEndpoint != nil {
    awsDynamoDBConfig.Endpoint = c.DynamoDBEndpoint
}

wdyt?

@phinze
Copy link
Contributor

phinze commented Jul 29, 2015

Thanks for this, @phstc - one inline question, and think you could add the attribute to the provider docs too?

@catsby catsby added enhancement waiting-response An issue/pull request is waiting for a response from the community provider/aws labels Jul 29, 2015
@@ -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"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phinze provider docs ^^^ updated 🍻

@catsby catsby removed the waiting-response An issue/pull request is waiting for a response from the community label Jul 29, 2015
@phstc
Copy link
Author

phstc commented Jul 29, 2015

@phinze not sure why the tests are failing make test is passing locally and the changes I did after the last successfully build were only on the docs.

@catsby
Copy link
Contributor

catsby commented Jul 30, 2015

@phstc there have been upstream changes to the config struct used by AWS. A simple merge from master and changing your config like so should do the trick:

awsDynamoDBConfig := &aws.Config{
  Credentials: creds,
  Region:      aws.String(c.Region),
  MaxRetries:  aws.Int(c.MaxRetries),
  Endpoint:    aws.String(c.DynamoDBEndpoint),
}

@catsby catsby added the waiting-response An issue/pull request is waiting for a response from the community label Jul 30, 2015
@phstc
Copy link
Author

phstc commented Jul 30, 2015

@catsby thanks! all set then:

All checks have passed

@phstc
Copy link
Author

phstc commented Jul 30, 2015

:shipit: ?

catsby added a commit that referenced this pull request Jul 30, 2015
provider/aws: Allow to change the DynamoDB Endpoint
@catsby catsby merged commit 649e2ab into hashicorp:master Jul 30, 2015
@catsby
Copy link
Contributor

catsby commented Jul 30, 2015

Thanks @phstc !

@phstc phstc deleted the dynamodb-local branch July 30, 2015 16:34
@phstc
Copy link
Author

phstc commented Jul 30, 2015

🤘

@catsby is there a new release on the schedule? or a mailing list to subscribe to get release updates? I will wait for a new release to update my work colleagues to start using terraform with dynamodb-local.

@catsby
Copy link
Contributor

catsby commented Jul 30, 2015

is there a new release on the schedule

I think next week, I'll double check

a mailing list to subscribe to get release updates

There is a mailing list here:

I don't know that we've been very diligent about announcing there. We typically tweet the announcement here https://twitter.com/hashicorp , e.g. https://twitter.com/hashicorp/status/623250629247520768

That said, we probably should announce on the list...

catsby added a commit that referenced this pull request Jul 30, 2015
* master: (720 commits)
  Update CHANGELOG.md
  Update CHANGELOG.md
  dynamodb-local Update AWS config #2825 (comment)
  Make target_pools optional
  Update CHANGELOG.md
  code formatting
  Update CHANGELOG.md
  providers/google: Fix reading account_file path
  providers/google: Fix error appending
  providers/google: Return if we could parse JSON
  providers/google: Change account_file to JSON
  providers/google: Default account_file* to empty
  providers/google: Add account_file/account_file_contents ConflictsWith
  providers/google: Document account_file_contents
  providers/google: Use account_file_contents if provided
  providers/google: Add account_file_contents to provider
  Update CHANGELOG.md
  Update CHANGELOG.md
  dynamodb-local Use ` instead of : to refer region to keep the consistency with the provider docs
  dynamodb-local Update aws provider docs to include the `dynamodb_endpoint` argument
  ...
@phstc
Copy link
Author

phstc commented Aug 5, 2015

@catsby thanks! You got a new follower 😄

@ghost
Copy link

ghost commented May 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DynamoDB local?
3 participants