aws_s3_bucket_object

    0

    0

    lucycodes42

    Terraform snippets

    Shortcut: tf_aws_s3_bucket_object

    data "aws_s3_bucket_object" "${lambda}" {
        bucket = "my-lambda-functions"
        key = "hello-world.zip"
    }
    
    resource "aws_iam_role" "iam_for_lambda" {
        name = "iam_for_lambda"
        assume_role_policy = <<EOF
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": "sts:AssumeRole",
                "Principal": {
                "Service": "lambda.amazonaws.com"
            },
                "Effect": "Allow",
                "Sid": ""
            }
        ]
    }
    EOF
    }
    
    resource "aws_lambda_function" "test_lambda" {
        s3_bucket = "\${data.aws_s3_bucket_object.${lambda}.bucket}"
        s3_key = "\${data.aws_s3_bucket_object.${lambda}.key}"
        s3_object_version = "\${data.aws_s3_bucket_object.${lambda}.version_id}"
        function_name = "lambda_function_name"
        role = "\${aws_iam_role.iam_for_lambda.arn}"
        handler = "exports.test"
    }
    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.