Skip to content

Instantly share code, notes, and snippets.

@rch317
Created September 13, 2019 15:28
Show Gist options
  • Save rch317/216993538c66c68238cb58ef36baeb94 to your computer and use it in GitHub Desktop.
Save rch317/216993538c66c68238cb58ef36baeb94 to your computer and use it in GitHub Desktop.
TF Interview Questions
// This Terraform code will fail. Aside from the obvious (no provider information, etc)...
// Please explain why this would fail, and what you can do to fix it?
// Policy template to be applied to our S3 bucket.
data "template_file" "policy" {
template = file("${path.module}/policy.tpl")
vars = {
bucket_name = aws_s3_bucket.bucket.id
}
}
// Create an S3 bucket using a bucket_prefix so that we get a unique but predictable name.
resource "aws_s3_bucket" "bucket" {
bucket_prefix = "my-s3-bucket-"
// Attach our policy from above to the S3 bucket.
policy = data.template_file.ct_policy.rendered
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment