data "aws_iam_policy_document" "${example}" {
         statement {
             sid = "1"
             actions = [
                 "s3:ListAllMyBuckets",
                 "s3:GetBucketLocation",
             ]
             resources = [
                 "arn:aws:s3:::*",
             ]
         }
      
         statement {
             actions = [
                 "s3:ListBucket",
             ]
             resources = [
                 "arn:aws:s3:::\${var.s3_bucket_name}",
             ]
             condition {
                 test = "StringLike"
                 variable = "s3:prefix"
                 values = [
                     "",
                     "home/",
                     "home/&{aws:username}/",
                 ]
             }
         }
      
         statement {
             actions = [
                 "s3:*",
             ]
             resources = [
                 "arn:aws:s3:::\${var.s3_bucket_name}/home/&{aws:username}",
                 "arn:aws:s3:::\${var.s3_bucket_name}/home/&{aws:username}/*",
             ]
         }
      }
      
      resource "aws_iam_policy" "${example}" {
         name = "example_policy"
         path = "/"
         policy = "\${data.aws_iam_policy_document.${example}.json}"
      }

      Terraform language logo
      aws_iam_policy_document

      Terraform snippets

      Shortcut: tf_aws_iam_policy_document

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.