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

Include access_key, secret_key, and session_token in aws_caller_identity #8517

Closed
wants to merge 1 commit into from
Closed

Include access_key, secret_key, and session_token in aws_caller_identity #8517

wants to merge 1 commit into from

Conversation

twang817
Copy link

@twang817 twang817 commented May 3, 2019

This allows local-exec provisioners to be able to retrieve the
credentials that the aws provider is using.

Ex:

provider "aws" {}
data "aws_caller_identity" "current" {}

resource "null_resource" "my_resource" {
  provisioner "local-exec" {
    command = "some-command"
    environment {
      AWS_ACCESS_KEY_ID = "${data.aws_caller_identity.current.access_key}"
      AWS_SECRET_ACCESS_KEY = "${data.aws_caller_identity.current.secret_key}"
      AWS_SESSION_TOKEN = "${data.aws_caller_identity.current.session_token}"
    }
  }
}

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #8242
Release note for CHANGELOG:

Allows credentials (access_key, secret_key, and session_token) to be fetched from aws_caller_identity to be used within local-exec provisioners.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

This allows local-exec provisioners to be able to retrieve the
credentials that the aws provider is using.

Ex:
```
provider "aws" {}
data "aws_caller_identity" "current" {}

resource "null_resource" "my_resource" {
  provisioner "local-exec" {
    command = "some-command"
    environment {
      AWS_ACCESS_KEY_ID = "${data.aws_caller_identity.current.access_key}"
      AWS_SECRET_ACCESS_KEY = "${data.aws_caller_identity.current.secret_key}"
      AWS_SESSION_TOKEN = "${data.aws_caller_identity.current.session_token}"
    }
  }
}

closes: #8242
```
@ghost ghost added size/S Managed by automation to categorize the size of a PR. service/sts Issues and PRs that pertain to the sts service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels May 3, 2019
@twang817
Copy link
Author

twang817 commented May 3, 2019

Having a little trouble running tests on my dinky laptop. Will try again on a bigger machine when I get the chance.

@aeschright aeschright requested a review from a team June 26, 2019 16:57
@jamroks
Copy link

jamroks commented Oct 2, 2019

Hi ,

Can we have an update on this issue, is it good enough to be merged or is there anything still blocking in order for it to be reviewed and merge ?

Thanks for clarification

@AyliD
Copy link

AyliD commented Oct 27, 2019

Any update on that?

@zopanix
Copy link
Contributor

zopanix commented Oct 30, 2019

@bflad Is it possible to have this reviewed ?

@twang817
Copy link
Author

I wrote this PR, but having recently been more involved with my company's security organization, I don't believe that this is a good solution to the problem.

Having keys stored in the tfstate, even if temporary, is a generally bad idea. Even worse, this implementation doesn't give users that may need aws_caller_identity a choice. Users could unwittingly publishing their potentially long-term keys through their tfstate into an unencrypted S3 bucket (or worse, Github!).

A slightly better solution would be to break this out into a separate data resource that can be used explicitly to fetch keys for those that are unconcerned with the security implications. I mentioned that I had done this in my last comment in #8242. I will close this and open a new PR with those changes.

@twang817 twang817 closed this Oct 30, 2019
@twang817 twang817 deleted the creds_in_calleridentiy branch October 31, 2019 04:33
@ghost
Copy link

ghost commented Mar 29, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/sts Issues and PRs that pertain to the sts service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass credentials to local-exec OR extract credentials via properties
4 participants