-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Vault AWS EC2 auth #190
Vault AWS EC2 auth #190
Conversation
Awesome! This'll need to be rebased now that #177 is merged. |
1ce039e
to
fba6ee6
Compare
vault/auth.go
Outdated
return "" | ||
} | ||
|
||
if skip := env.Getenv("VAULT_AUTH_AWS_EC2_SKIP", ""); skip != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if VAULT_AUTH_AWS_METHOD
is required (i.e. must be set to ec2
, and doesn't default), then this environment variable can be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of moving it last in the order so both environment variables can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't VAULT_AUTH_AWS_METHOD
required to differentiate between ec2
and iam
? Or do you mean you'd default to ec2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as moving it last in order, that's probably fine. There are cases where I use gomplate in CI environments and pass it a VAULT_TOKEN
var so it can auth correctly. Those CI environments are generally in EC2, so it'd be good to not get tripped up there.
vault/auth.go
Outdated
logFatal("Invalid AWS_TIMEOUT value '%s' - must be an integer\n", timeout) | ||
} | ||
|
||
opts.Timeout = time.Duration(t) * time.Millisecond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just exposed a new MustAtoi
in github.com/hairyhenderson/gomplate/typeconv
, so you can do this instead:
opts.Timeout = time.Duration(typeconv.MustAtoi(os.Getenv("AWS_TIMEOUT"))) * time.Millisecond
e04d302
to
008b470
Compare
I'm just trying to add some integration tests. |
008b470
to
e12ab99
Compare
vault/auth.go
Outdated
opts := aws.ClientOptions{} | ||
|
||
timeout := os.Getenv("AWS_TIMEOUT") | ||
if timeout != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually no need to have this check, because opts.Timeout
's default is 0
anyways. There's no harm to simply setting it to 0
explicitly.
You could make things even simpler by setting Timeout
while creating the struct (up on ln169):
opts := aws.ClientOptions{
Timeout: time.Duration(typeconv.MustAtoi(os.Getenv("AWS_TIMEOUT"))) * time.Millisecond,
}
e12ab99
to
b770275
Compare
@hairyhenderson could you take a look at this now? |
@stuart-c the integration test is failing:
|
vault/auth.go
Outdated
meta := aws.NewEc2Meta(opts) | ||
|
||
if endpoint := env.Getenv("AWS_META_ENDPOINT"); endpoint != "" { | ||
meta.Endpoint = endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this block belongs here instead: https://github.com/hairyhenderson/gomplate/blob/master/aws/ec2meta.go#L89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean you'd prefer the AWS_META_ENDPOINT to be set in the ec2meta file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer it to be read there - so that the metadata endpoint can be overridden in general, not just when using Vault EC2 auth
vault/auth.go
Outdated
meta.Endpoint = endpoint | ||
} | ||
|
||
vars["pkcs7"] = strings.Replace(strings.TrimSpace(meta.Dynamic("instance-identity/pkcs7")), "\n", "", -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the extra strings.Replace
? strings.TrimSpace
will trim off \n
characters... Or is this intended to remove all newlines in the middle of the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep all embedded newlines need to be removed.
Ah - it's because the version of Vault in |
@stuart-c can you bump the Vault version in https://github.com/hairyhenderson/gomplate/blob/master/test/integration/Dockerfile#L3 so that |
That is now fixed, but the tests are hanging a bit further down. Not sure what's going on. Is it working for you locally? |
4d92a7a
to
fe1abe7
Compare
Looks like you accidentally committed |
Maybe related to a CircleCI issue: https://status.circleci.com/incidents/1hf3n7yf8zrn? |
fe1abe7
to
02b6591
Compare
Fixed the .gitignore |
Looks to be a bats bug which I think I've now worked around... So I think everything should now be good @hairyhenderson? |
This requires #177 to be merged first.
Add AWS ec2 auth support for Vault.