Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 2b686bd

Browse files
authored
TF - 0.13 upgrade (#30)
* TF - 0.13 upgrade * nits * nits * nits * nits
1 parent 4dc75b1 commit 2b686bd

File tree

41 files changed

+324
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+324
-253
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM puneethn/terraform-test-workhorse:0.12.25
1+
FROM puneethn/terraform-test-workhorse:0.13.5
22

33
WORKDIR /go/src/github.com/comtravo/terraform-aws-lambda
44
COPY . .

Jenkinsfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pipeline {
2323
script {
2424
try {
2525
sh(label: 'Building docker image', script: "make build")
26-
sh(label: 'Testing docker image', script: "make test-docker")
26+
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'automated-infra-testing-account', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
27+
sh(label: 'Testing docker image', script: "make test-docker")
28+
}
2729
} finally {
2830
sh(label: 'Cleanup', script: "make clean-all")
2931
}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
DOCKER_COMPOSE=docker-compose -f ./docker-compose.yml
44
DOCKER_COMPOSE_DEVELOP=$(DOCKER_COMPOSE) -f ./docker-compose.develop.yml
5-
GENERATE_DOCS_COMMAND:=terraform-docs --sort-inputs-by-required markdown --no-escape . > README.md
5+
GENERATE_DOCS_COMMAND:=terraform-docs markdown . > README.md
66

77
fmt:
88
@terraform fmt -recursive
@@ -16,10 +16,10 @@ lint:
1616
build:
1717
@$(DOCKER_COMPOSE) build
1818

19-
test-localstack:
20-
@cd test && go test -tags=localstack
19+
test-aws:
20+
@cd test && go test -tags=aws
2121

22-
test-all: test-localstack
22+
test-all: test-aws
2323

2424
test-docker:
2525
@$(DOCKER_COMPOSE) run --rm terraform make lint

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MIT Licensed. See LICENSE for full details.
1717

1818
| Name | Version |
1919
|------|---------|
20-
| terraform | >= 0.12 |
20+
| terraform | >= 0.13 |
2121
| aws | ~> 3.0 |
2222

2323
## Providers
@@ -30,36 +30,35 @@ MIT Licensed. See LICENSE for full details.
3030

3131
| Name | Description | Type | Default | Required |
3232
|------|-------------|------|---------|:--------:|
33-
| file_name | Lambda function filename name | `string` | n/a | yes |
34-
| function_name | Lambda function name | `string` | n/a | yes |
35-
| handler | Lambda function handler | `string` | n/a | yes |
36-
| region | AWS region | `string` | n/a | yes |
37-
| role | Lambda function role | `string` | n/a | yes |
38-
| trigger | Trigger configuration for this lambda function | `any` | n/a | yes |
39-
| cloudwatch_log_retention | Enable Cloudwatch logs retention | `number` | `90` | no |
40-
| cloudwatch_log_subscription | Cloudwatch log stream configuration | <pre>object({<br> enable : bool<br> filter_pattern : string<br> destination_arn : string<br> })</pre> | <pre>{<br> "destination_arn": "",<br> "enable": false,<br> "filter_pattern": ""<br>}</pre> | no |
33+
| cloudwatch\_log\_retention | Enable Cloudwatch logs retention | `number` | `90` | no |
34+
| cloudwatch\_log\_subscription | Cloudwatch log stream configuration | <pre>object({<br> enable : bool<br> filter_pattern : string<br> destination_arn : string<br> })</pre> | <pre>{<br> "destination_arn": "",<br> "enable": false,<br> "filter_pattern": ""<br>}</pre> | no |
4135
| description | Lambda function description | `string` | `"Managed by Terraform"` | no |
4236
| environment | Lambda environment variables | `map(string)` | `null` | no |
37+
| file\_name | Lambda function filename name | `string` | n/a | yes |
38+
| function\_name | Lambda function name | `string` | n/a | yes |
39+
| handler | Lambda function handler | `string` | n/a | yes |
4340
| layers | List of layers for this lambda function | `list(string)` | `[]` | no |
44-
| memory_size | Lambda function memory size | `number` | `128` | no |
41+
| memory\_size | Lambda function memory size | `number` | `128` | no |
4542
| publish | Publish lambda function | `bool` | `false` | no |
46-
| reserved_concurrent_executions | Reserved concurrent executions for this lambda function | `number` | `-1` | no |
43+
| region | AWS region | `string` | n/a | yes |
44+
| reserved\_concurrent\_executions | Reserved concurrent executions for this lambda function | `number` | `-1` | no |
45+
| role | Lambda function role | `string` | n/a | yes |
4746
| runtime | Lambda function runtime | `string` | `"nodejs12.x"` | no |
4847
| tags | Tags for this lambda function | `map(string)` | `{}` | no |
4948
| timeout | Lambda function runtime | `number` | `300` | no |
50-
| tracing_config | https://www.terraform.io/docs/providers/aws/r/lambda_function.html | <pre>object({<br> mode : string<br> })</pre> | <pre>{<br> "mode": "PassThrough"<br>}</pre> | no |
51-
| vpc_config | Lambda VPC configuration | <pre>object({<br> subnet_ids : list(string)<br> security_group_ids : list(string)<br> })</pre> | <pre>{<br> "security_group_ids": [],<br> "subnet_ids": []<br>}</pre> | no |
49+
| tracing\_config | https://www.terraform.io/docs/providers/aws/r/lambda_function.html | <pre>object({<br> mode : string<br> })</pre> | <pre>{<br> "mode": "PassThrough"<br>}</pre> | no |
50+
| trigger | Trigger configuration for this lambda function | `any` | n/a | yes |
51+
| vpc\_config | Lambda VPC configuration | <pre>object({<br> subnet_ids : list(string)<br> security_group_ids : list(string)<br> })</pre> | <pre>{<br> "security_group_ids": [],<br> "subnet_ids": []<br>}</pre> | no |
5252

5353
## Outputs
5454

5555
| Name | Description |
5656
|------|-------------|
5757
| arn | AWS lambda arn |
5858
| dlq | AWS lambda Dead Letter Queue details |
59-
| function_name | AWS lambda function name |
60-
| invoke_arn | AWS lambda invoke_arn |
61-
| qualified_arn | AWS lambda qualified_arn |
59+
| function\_name | AWS lambda function name |
60+
| invoke\_arn | AWS lambda invoke\_arn |
61+
| qualified\_arn | AWS lambda qualified\_arn |
6262
| queue | AWS lambda SQS details |
63-
| sns_topics | AWS lambda SNS topics if any |
63+
| sns\_topics | AWS lambda SNS topics if any |
6464
| version | AWS lambda version |
65-

docker-compose.develop.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,5 @@ services:
55
command: bash
66
volumes:
77
- ./:/go/src/github.com/comtravo/terraform-aws-lambda
8-
9-
localstack:
10-
ports:
11-
- 4566:4566
12-
- 4584-4597:4584-4597
13-
- 4567-4583:4567-4583
14-
- 8080:8080
8+
environment:
9+
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-foo} # automated infra testing acc creds

docker-compose.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,5 @@ services:
99
environment:
1010
- AWS_REGION=us-east-1
1111
- AWS_DEFAULT_REGION=us-east-1
12-
- AWS_ACCESS_KEY_ID=foo
13-
- AWS_SECRET_ACCESS_KEY=bar
14-
- LOCALSTACK_HOST=localstack
15-
depends_on:
16-
- localstack
17-
18-
localstack:
19-
image: localstack/localstack:0.11.4
20-
environment:
21-
- SERVICES=events,iam,logs,lambda,sns,sqs,sts
22-
- AWS_REGION=us-east-1
23-
- AWS_DEFAULT_REGION=us-east-1
24-
- DEFAULT_REGIONc=us-east-1
25-
- DOCKER_HOST=unix:///var/run/docker.sock
26-
- DATA_DIR=/tmp/localstack/data
27-
- DEBUG=1
28-
volumes:
29-
- "/var/run/docker.sock:/var/run/docker.sock"
30-
- "localstack-data:/tmp/localstack"
31-
32-
volumes:
33-
localstack-data:
12+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-foo} # automated infra testing acc creds
13+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-foo} # automated infra testing acc creds

examples/api_gateway_trigger/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module "api_gatewat_trigger" {
4242
file_name = "${path.module}/../../test/fixtures/foo.zip"
4343
function_name = var.function_name
4444
handler = "index.handler"
45-
role = aws_iam_role.lambda.name
45+
role = aws_iam_role.lambda.arn
4646
trigger = {
4747
type = "api-gateway"
4848
}

examples/cloudwatch_event_pattern_trigger/main.tf

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,32 @@ module "cloudwatch_event_pattern_trigger" {
4242
file_name = "${path.module}/../../test/fixtures/foo.zip"
4343
function_name = var.function_name
4444
handler = "index.handler"
45-
role = aws_iam_role.lambda.name
45+
role = aws_iam_role.lambda.arn
4646
trigger = {
47-
type = "cloudwatch-event-trigger"
48-
schedule_expression = "{}"
47+
type = "cloudwatch-event-trigger"
48+
event_pattern = <<PATTERN
49+
{
50+
"source": [
51+
"aws.s3"
52+
],
53+
"detail-type": [
54+
"AWS API Call via CloudTrail"
55+
],
56+
"detail": {
57+
"eventSource": [
58+
"s3.amazonaws.com"
59+
],
60+
"eventName": [
61+
"PutObject"
62+
],
63+
"requestParameters": {
64+
"bucketName": [
65+
"foo-bar-baz"
66+
]
67+
}
68+
}
69+
}
70+
PATTERN
4971
}
5072
environment = {
5173
"LOREM" = "IPSUM"

examples/cloudwatch_event_schedule_trigger/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module "cloudwatch_event_schedule_trigger" {
4242
file_name = "${path.module}/../../test/fixtures/foo.zip"
4343
function_name = var.function_name
4444
handler = "index.handler"
45-
role = aws_iam_role.lambda.name
45+
role = aws_iam_role.lambda.arn
4646
trigger = {
4747
type = "cloudwatch-event-schedule"
4848
schedule_expression = "cron(0 1 * * ? *)"

0 commit comments

Comments
 (0)