Skip to content

Commit

Permalink
Merge pull request #83 from kookmin-sw/mhsong-dev
Browse files Browse the repository at this point in the history
Lambda Function name 랜덤화
  • Loading branch information
mh3ong authored May 19, 2024
2 parents 463af5c + 3e4928b commit 5ccd207
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions IaC/serverless_api_template/lambda/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
provider "random" {}

resource "random_id" "random_string" {
byte_length = 8
}

resource "aws_iam_role" "lambda-role" {
name = "${var.prefix}-aws-lambda-role"
name = "${var.prefix}-aws-lambda-role-${random_id.random_string.hex}"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand Down Expand Up @@ -75,7 +81,7 @@ resource "aws_iam_role_policy_attachment" "iam_policy" {
}

resource "aws_lambda_function" "lambda" {
function_name = "${var.prefix}-aws-lambda"
function_name = "${var.prefix}-aws-lambda-${random_id.random_string.hex}"
package_type = "Image"
architectures = ["x86_64"]
image_uri = "${var.container_registry}/${var.container_repository}:${var.container_image_tag}"
Expand Down

0 comments on commit 5ccd207

Please sign in to comment.