github.com/winebarrel/terraform-provider-lambdazip@v0.6.1-0.20240313233639-361839f8c5c5/docs/resources/file.md (about) 1 --- 2 # generated by https://github.com/hashicorp/terraform-plugin-docs 3 page_title: "lambdazip_file Resource - lambdazip" 4 subcategory: "" 5 description: |- 6 7 --- 8 9 # lambdazip_file (Resource) 10 11 12 13 ## Example Usage 14 15 ```terraform 16 terraform { 17 required_providers { 18 lambdazip = { 19 source = "winebarrel/lambdazip" 20 version = ">= 0.5.0" 21 } 22 } 23 } 24 25 resource "lambdazip_file" "app" { 26 base_dir = "lambda" 27 sources = ["**"] 28 excludes = [".env"] 29 output = "lambda.zip" 30 before_create = "npm i" 31 32 triggers = { 33 for i in [ 34 "lambda/index.js", 35 "lambda/package.json", 36 "lambda/package-lock.json", 37 ] : i => filesha256(i) 38 } 39 } 40 41 resource "aws_lambda_function" "app" { 42 filename = lambdazip_file.app.output 43 function_name = "my_func" 44 role = aws_iam_role.lambda_app_role.arn 45 handler = "index.handler" 46 source_code_hash = lambdazip_file.app.base64sha256 47 runtime = "nodejs20.x" 48 } 49 50 resource "aws_iam_role" "lambda_app_role" { 51 name = "lambda-app-role" 52 53 assume_role_policy = jsonencode({ 54 Version = "2012-10-17" 55 Statement = [ 56 { 57 Effect = "Allow" 58 Principal = { 59 Service = "lambda.amazonaws.com" 60 } 61 Action = "sts:AssumeRole" 62 } 63 ] 64 }) 65 } 66 67 resource "aws_iam_role_policy_attachment" "lambda_app_role" { 68 role = aws_iam_role.lambda_app_role.name 69 policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" 70 } 71 ``` 72 73 <!-- schema generated by tfplugindocs --> 74 ## Schema 75 76 ### Required 77 78 - `output` (String) 79 - `sources` (List of String) 80 - `triggers` (Map of String) 81 82 ### Optional 83 84 - `base_dir` (String) 85 - `before_create` (String) 86 - `excludes` (List of String) 87 88 ### Read-Only 89 90 - `base64sha256` (String) 91 - `id` (String) The ID of this resource.