aws_iam_policy_document

    0

    0

    lucycodes42

    Terraform snippets

    Shortcut: tf_aws_iam_policy_document

    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}"
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.