Skip to content

Commit

Permalink
more random IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
haitchison committed Jan 3, 2024
1 parent 147eaf4 commit d443407
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions test/unit-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module "module_test" {
role_name = format("InstanceSchedulerLambdaFunctionPolicy-%s", random_id.role.dec)
policy_json_attached = true
policy_json = data.aws_iam_policy_document.instance-scheduler-lambda-function-policy.json
function_name = "instance-scheduler-lambda-function"
function_name = format("instance-scheduler-lambda-function-%s", random_id.lambda.dec)
create_role = true
reserved_concurrent_executions = 1
environment_variables = {
Expand All @@ -30,10 +30,6 @@ module "module_test" {

}

resource "random_id" "role" {
byte_length = 1
}

resource "aws_cloudwatch_event_rule" "instance_scheduler_weekly_stop_at_night" {
name = "instance_scheduler_weekly_stop_at_night"
description = "Call Instance Scheduler with Stop action at 8:00 pm (UTC) every Monday through Friday"
Expand Down Expand Up @@ -173,7 +169,7 @@ module "lambda_function_in_vpc" {
handler = "test.lambda_handler"
runtime = "python3.8"
tags = local.tags
function_name = "lambda-function-in-vpc-test"
function_name = format("lambda-function-in-vpc-test-%s", random_id.lambda_name.dec)
create_role = false
lambda_role = aws_iam_role.lambda-vpc-role.arn

Expand All @@ -193,10 +189,6 @@ data "aws_iam_policy_document" "lambda_assume_role_policy" {
}
}

resource "random_id" "role_name" {
byte_length = 1
}

resource "aws_iam_role" "lambda-vpc-role" {
name = format("LambdaFunctionVPCAccess-%s", random_id.role_name.dec)
tags = local.tags
Expand All @@ -217,10 +209,6 @@ data "aws_subnet" "private-2a" {
id = "subnet-0e2a4d5f4b346c981"
}

resource "random_id" "sg_name" {
byte_length = 1
}

resource "aws_security_group" "lambda_security_group_test" {
name = format("lambda-vpc-module-test-%s", random_id.sg_name.dec)
description = "lambda attached to vpc test security group"
Expand Down Expand Up @@ -250,3 +238,25 @@ resource "aws_lambda_invocation" "test_vpc_invocation" {
action = "Test"
})
}

# temporary random IDs

resource "random_id" "lambda_name" {
byte_length = 1
}

resource "random_id" "role" {
byte_length = 1
}

resource "random_id" "lambda" {
byte_length = 1
}

resource "random_id" "sg_name" {
byte_length = 1
}

resource "random_id" "role_name" {
byte_length = 1
}

0 comments on commit d443407

Please sign in to comment.