-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
New Data Source: aws_iam_policy #1999
New Data Source: aws_iam_policy #1999
Conversation
Schema: map[string]*schema.Schema{ | ||
"arn": { | ||
Type: schema.TypeString, | ||
Optional: true, |
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 would define as Required: true
instead
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.
@darkowlzz this data source is a great contribution; I certainly know I have been looking for it a few times. I'm hoping you or others will enhance it in the future so it can lookup AWS provided policies by name to fetch their ARN. 😄
This just does need the one change mentioned by @trung about making arn
required instead of optional since in its current form that's the only lookup available. I'll get that really simple change in a commit after your commits and merge. Thanks again.
make testacc TEST=./aws TESTARGS='-run=TestAccAWSDataSourceIAMPolicy_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDataSourceIAMPolicy_basic -timeout 120m
=== RUN TestAccAWSDataSourceIAMPolicy_basic
--- PASS: TestAccAWSDataSourceIAMPolicy_basic (11.67s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 11.715s
This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
Hi @bflad,
Error: output 'policy': unknown resource 'aws_iam_policy.AdministratorAccess' referenced in variable aws_iam_policy.AdministratorAccess.arn |
@chris-weck for Terraform data sources you need to prepend output "policy" {
value = "${data.aws_iam_policy.AdministratorAccess.arn}"
}
|
Oh, many thanks. I´m new with terraform. It´s working now :) |
Quoting @bflad:
Ran into this and was surprised it requires an This looks like a nice thing to pick up and get my feet wet on contributing to Terraform. What would be a good pattern to follow? As
First seems best imo. Opinions? |
@TBeijen its probably fine to raise an error for now. You can cross-add |
@TBeijen are you still wanting to pick this up? I was just looking at this data source as I currently build the ARN of our managed policies and it would be nicer if we could just refer to it by name. Also I would probably go with your third option where any combination of things can be specified but they still have to return exactly one result. So something like this should be fine: data "aws_iam_policy" "AdministratorAccess" {
arn = "arn:aws:iam::aws:policy/AdministratorAccess"
name = "AdministratorAccess"
path = "policy"
} But this would fail: data "aws_iam_policy" "AdministratorAccess" {
arn = "arn:aws:iam::aws:policy/AdministratorAccess"
name = "ReadOnlyAccess"
path = "policy"
} It would also be good to export/consume the account ID (also allowing for the magic |
Hi @tomelliff, Feel free to pick this up, no risk of efforts crossing. Btw, I would surely consider approach 1 from my previous comment, unless ofc. you have a use case that would require specifying both |
I don't have an urgent need for it (just cleans up some code) so if you think you'd be able to look at it in the next month or so and did want to get your feet wet then I'll leave it for you. If not then I'll think about picking this up when I get some free time later this week. |
@TBeijen @tomelliff any update in this? |
@saravanan30erd Above is still 100% accurate, so no progress from my part. |
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! |
fixes #1346