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

resource aws_iam_access_key doesn't support import #17288

Closed
cedricbastin opened this issue Jan 26, 2021 · 5 comments · Fixed by #17321
Closed

resource aws_iam_access_key doesn't support import #17288

cedricbastin opened this issue Jan 26, 2021 · 5 comments · Fixed by #17321
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@cedricbastin
Copy link

cedricbastin commented Jan 26, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Make it possible to import AWS IAM Access Keys that were manually via the AWS Console. It should be possible to run
terraform import aws_iam_access_key.my_access_key <Access Key ID> and bring them under Terraform management.

Currently this is not supported and results in the error message: resource aws_iam_access_key doesn't support import.

Affected Resource

  • aws_iam_access_key

Potential Terraform Configuration

resource "aws_iam_access_key" "my_access_key" {
  user = "${aws_iam_user.my_user.name}"
}

References

@cedricbastin cedricbastin added the enhancement Requests to existing resources that expand the functionality or scope. label Jan 26, 2021
@ghost ghost added the service/iam Issues and PRs that pertain to the iam service. label Jan 26, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 26, 2021
@bflad bflad self-assigned this Jan 27, 2021
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Jan 27, 2021
@bflad
Copy link
Contributor

bflad commented Jan 27, 2021

Hi @cedricbastin 👋 Thank you for raising this. We can certainly add import support for the resource. Please note though, that the IAM API does not provide a method for fetching the secret, so imported resources cannot provide that that information. Imported resources will however be able to perform status updates and be deleted, which is still useful.

bflad added a commit that referenced this issue Jan 28, 2021
Reference: #17288

Output from acceptance testing:

```
--- PASS: TestAccAWSAccessKey_encrypted (12.92s)
--- PASS: TestAccAWSAccessKey_basic (12.92s)
--- PASS: TestAccAWSAccessKey_inactive (19.64s)
```
@cedricbastin
Copy link
Author

@bflad Thanks for getting back to me and for clarifying this, I was also wondering about this! 👍
There would still be value in tracking the existence of the keys in code, for inventory reasons.
Would it be possible for Terraform to warn about old (> x days) access keys during a plan/apply?

@bflad
Copy link
Contributor

bflad commented Jan 28, 2021

@cedricbastin not with the Terraform AWS Provider itself -- its primary function is to map AWS APIs onto Terraform resources. This is typically a space for Policy as Code/Configuration tooling such as Sentinel, Open Policy Agent, etc. which can provide informational, warning, or failure information based on Terraform configuration or state.

bflad added a commit that referenced this issue Jan 29, 2021
* resource/aws_iam_access_key: Support resource import

Reference: #17288

Output from acceptance testing:

```
--- PASS: TestAccAWSAccessKey_encrypted (12.92s)
--- PASS: TestAccAWSAccessKey_basic (12.92s)
--- PASS: TestAccAWSAccessKey_inactive (19.64s)
```

* Update CHANGELOG for #17321
@github-actions github-actions bot added this to the v3.27.0 milestone Jan 29, 2021
@ghost
Copy link

ghost commented Feb 5, 2021

This has been released in version 3.27.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 1, 2021

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 as resolved and limited conversation to collaborators Mar 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants