2 ms·
Anyone from Hashicorp -- y'all are gonna end me. Please put the best way to do things into your own docs. You have https://www.terraform.io/docs/providers/aws
by chucky_z 7y ago
Anyone from Hashicorp -- y'all are gonna end me. Please put the best way to do things into your own docs. You have https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html https://www.terraform.io/docs/providers/aws/d/iam_policy_doc... and can do
data "aws_iam_policy_document" "s3_bucket" {
version = "2012-10-17"
statement {
sid = "PublicReadGetObject"
principals {
type = "*"
identifiers = ["*"]
}
actions = [
"s3:GetObject"
]
resources = [
"arn:aws:s3:::${var.bucket_name}/*"
]
}
}
resource "aws_s3_bucket" "s3_bucket" {
bucket = var.bucket_name
acl = "public-read"
policy = data.aws_iam_policy_document.s3_bucket.json
website {
index_document = "index.html"
error_document = "error.html"
}
tags = var.tags
}
- pmh 7y agoFWIW, the "Learn" link on terraform.io goes to the same codelabs in the blog and there's some existing guidance in the docs. I don't mind separate domains for these kinds of things, but I agree that they should at least add links in the docs.
- leetrout 7y agoAre you referring to the learn guide demonstrating the policy JSON reference in the aws_s3_bucket.policy vs the provider documentation demonstrating the reference inside an aws_iam_policy.policy?
- chucky_z 7y agoThe guide. Also, like, most of their examples ignore this data resource. That specific data resource, with terraform 0.12 makes building IAMs so much nicer, because you can mash a bunch of common ones together with for_each and generate policies in a dynamic way without having to learn dynamic IAM stuff, which is it's own thing entirely.
- Legogris 7y agoOh, or like the Consul TLS tutorial from two weeks back, which had (has?) invalid configuration examples and incorrect documentation. As much documentation as they have, Hashicorp products can be very confusing.