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

Add AWS_DYNAMODB_REGION Environment variable #15054

Merged
merged 4 commits into from
Apr 28, 2022

Conversation

sergeylanzman
Copy link
Contributor

@sergeylanzman sergeylanzman commented Apr 14, 2022

From eks 1.18 AWS_REGION and AWS_DEFAULT_REGION auto inject to pods. So if you can't use dynamodb table from other region it's read from AWS_REGION always and override on config file. Reorder setting can be break current vault settings. I added one new with AWS_DYNAMODB_REGION

aws/amazon-eks-pod-identity-webhook#40

fix #15071

changelog

storage/dynamodb: Added `AWS_DYNAMODB_REGION` environment variable

@hashicorp-cla
Copy link

hashicorp-cla commented Apr 14, 2022

CLA assistant check
All committers have signed the CLA.

@hsimon-hashicorp
Copy link
Contributor

Hi! Can you please also open and link a GitHub issue? Please don't forget a changelog entry, too. Thanks! :)

@sergeylanzman sergeylanzman changed the title Patch 1 Add AWS_DYNAMODB_REGION Environment variable Apr 17, 2022
@sergeylanzman
Copy link
Contributor Author

@hsimon-hashicorp Added issue. How I can add changelog? can you point me to example?

@hsimon-hashicorp
Copy link
Contributor

@hsimon-hashicorp Added issue. How I can add changelog? can you point me to example?

Thank you for the issue! Adding a changelog entry is described in the CONTRIBUTING.md. Thanks! :)

swenson
swenson previously approved these changes Apr 28, 2022
Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

This seems pretty reasonable to me. Thanks for this!

changelog/15054.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

Oops, I just saw the extra empty lines in the changelog file. Please remove those.

@swenson swenson dismissed their stale review April 28, 2022 18:11

Missed blank lines

@sergeylanzman
Copy link
Contributor Author

Done

Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

@swenson swenson merged commit 0be45d0 into hashicorp:main Apr 28, 2022
@@ -163,13 +163,16 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac
if endpoint == "" {
endpoint = conf["endpoint"]
}
region := os.Getenv("AWS_REGION")
region := os.Getenv("AWS_DYNAMODB_REGION")
Copy link
Member

Choose a reason for hiding this comment

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

@swenson I wonder if using a switch is cleaner instead of deep nesting. I know that we have this pattern for the other config params, but since we're evaluating several env vars for this one it might not be a bad idea?

	var region string
	switch {
	case os.Getenv("AWS_DYNAMODB_REGION") != "":
		region = os.Getenv("AWS_DYNAMODB_REGION")
	case os.Getenv("AWS_REGION") != "":
		region = os.Getenv("AWS_REGION")
	case os.Getenv("AWS_DEFAULT_REGION") != "":
		region = os.Getenv("AWS_DEFAULT_REGION")
	case conf["region"] != "":
		region = conf["region"]
	default:
		region = DefaultDynamoDBRegion
	}

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I was thinking that the deep nesting was a little bit much. The switch is much cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override AWS_REGION Environment variable
5 participants