Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add date to resources names for dynamo and lambda event source mapping acceptance tests #336

Merged
merged 2 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions pkg/resource/aws/testdata/acc/aws_dynamodb_table/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ provider "aws" {
region = "us-east-1"
}

resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
locals {
timestamp = formatdate("YYYYMMDDhhmmss", timestamp())
}

resource "aws_dynamodb_table" "simple-dynamo-test" {
name = "simple-dynamo-test-${local.timestamp}"
billing_mode = "PROVISIONED"
read_capacity = 20
write_capacity = 20
Expand Down Expand Up @@ -46,8 +50,8 @@ resource "aws_dynamodb_table" "basic-dynamodb-table" {
}
}

resource "aws_dynamodb_table" "example" {
name = "example"
resource "aws_dynamodb_table" "global-dynamo-test" {
name = "global-dynamo-test-${local.timestamp}"
hash_key = "TestTableHashKey"
billing_mode = "PAY_PER_REQUEST"
stream_enabled = true
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ provider "aws" {
region = "us-east-1"
}

locals {
timestamp = formatdate("YYYYMMDDhhmmss", timestamp())
}

resource "aws_sqs_queue" "queue1" {
name = "queue1"
name = "queue1-${local.timestamp}"
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
receive_wait_time_seconds = 10
}

resource "aws_sqs_queue" "queue2" {
name = "queue2"
name = "queue2-${local.timestamp}"
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
receive_wait_time_seconds = 10
}

resource "aws_dynamodb_table" "example" {
name = "example"
resource "aws_dynamodb_table" "dynamo-event-source-mapping-test" {
name = "event-source-mapping-test-${local.timestamp}"
hash_key = "TestTableHashKey"
billing_mode = "PAY_PER_REQUEST"
stream_enabled = true
Expand All @@ -32,7 +36,7 @@ resource "aws_dynamodb_table" "example" {
}

resource "aws_iam_role" "iam_for_lambda" {
name = "iam_for_lambda"
name = "iam_for_lambda-${local.timestamp}"

assume_role_policy = <<EOF
{
Expand All @@ -52,7 +56,7 @@ EOF
}

resource "aws_iam_policy" "policy" {
name = "policy"
name = "policy-${local.timestamp}"

policy = <<EOF
{
Expand All @@ -78,14 +82,14 @@ EOF
}

resource "aws_iam_policy_attachment" "policy_attachment" {
name = "attachment"
name = "event-source-mapping-test-attachment-${local.timestamp}"
roles = [aws_iam_role.iam_for_lambda.name]
policy_arn = aws_iam_policy.policy.arn
}

resource "aws_lambda_function" "test_lambda" {
filename = "function.zip"
function_name = "lambda_function_name"
function_name = "event-source-mapping-test-lambda-${local.timestamp}"
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.test"
runtime = "nodejs12.x"
Expand All @@ -112,7 +116,7 @@ resource "aws_lambda_event_source_mapping" "sqs2" {
}

resource "aws_lambda_event_source_mapping" "dynamo" {
event_source_arn = aws_dynamodb_table.example.stream_arn
event_source_arn = aws_dynamodb_table.dynamo-event-source-mapping-test.stream_arn
function_name = aws_lambda_function.test_lambda.arn
starting_position = "LATEST"
}
}