Created
December 30, 2022 14:58
-
-
Save onelharrison/62508ad4fa777dc6af2d3b2305b95a64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "env_name" { | |
description = "Environment name" | |
} | |
data "aws_ecr_repository" "profile_faker_ecr_repo" { | |
name = "profile-faker" | |
} | |
resource "aws_lambda_function" "profile_faker_function" { | |
function_name = "profile-faker-${var.env_name}" | |
timeout = 5 # seconds | |
image_uri = "${data.aws_ecr_repository.profile_faker_ecr_repo.repository_url}:${var.env_name}" | |
package_type = "Image" | |
role = aws_iam_role.profile_faker_function_role.arn | |
environment { | |
variables = { | |
ENVIRONMENT = var.env_name | |
} | |
} | |
} | |
resource "aws_iam_role" "profile_faker_function_role" { | |
name = "profile-faker-${var.env_name}" | |
assume_role_policy = jsonencode({ | |
Statement = [ | |
{ | |
Action = "sts:AssumeRole" | |
Effect = "Allow" | |
Principal = { | |
Service = "lambda.amazonaws.com" | |
} | |
}, | |
] | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment