diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 31f18fa..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. -on: - pull_request: - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: build - run: make build - - - name: test - run: make test-docker diff --git a/Dockerfile b/Dockerfile index fc46e63..a8291e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM puneethn/terraform-test-workhorse:0.12.25 +FROM puneethn/terraform-test-workhorse:0.13.5 WORKDIR /go/src/github.com/comtravo/terraform-aws-lambda COPY . . diff --git a/Jenkinsfile b/Jenkinsfile index 6436409..738d7ff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,9 @@ pipeline { script { try { sh(label: 'Building docker image', script: "make build") - sh(label: 'Testing docker image', script: "make test-docker") + withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'automated-infra-testing-account', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) { + sh(label: 'Testing docker image', script: "make test-docker") + } } finally { sh(label: 'Cleanup', script: "make clean-all") } diff --git a/Makefile b/Makefile index 35e21f1..e13889b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ DOCKER_COMPOSE=docker-compose -f ./docker-compose.yml DOCKER_COMPOSE_DEVELOP=$(DOCKER_COMPOSE) -f ./docker-compose.develop.yml -GENERATE_DOCS_COMMAND:=terraform-docs --sort-inputs-by-required markdown --no-escape . > README.md +GENERATE_DOCS_COMMAND:=terraform-docs markdown . > README.md fmt: @terraform fmt -recursive @@ -16,10 +16,10 @@ lint: build: @$(DOCKER_COMPOSE) build -test-localstack: - @cd test && go test -tags=localstack +test-aws: + @cd test && go test -tags=aws -test-all: test-localstack +test-all: test-aws test-docker: @$(DOCKER_COMPOSE) run --rm terraform make lint diff --git a/README.md b/README.md index d938126..73afe22 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ MIT Licensed. See LICENSE for full details. | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -30,25 +30,25 @@ MIT Licensed. See LICENSE for full details. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| file_name | Lambda function filename name | `string` | n/a | yes | -| function_name | Lambda function name | `string` | n/a | yes | -| handler | Lambda function handler | `string` | n/a | yes | -| region | AWS region | `string` | n/a | yes | -| role | Lambda function role | `string` | n/a | yes | -| trigger | Trigger configuration for this lambda function | `any` | n/a | yes | -| cloudwatch_log_retention | Enable Cloudwatch logs retention | `number` | `90` | no | -| cloudwatch_log_subscription | Cloudwatch log stream configuration |
object({|
enable : bool
filter_pattern : string
destination_arn : string
})
{| no | +| cloudwatch\_log\_retention | Enable Cloudwatch logs retention | `number` | `90` | no | +| cloudwatch\_log\_subscription | Cloudwatch log stream configuration |
"destination_arn": "",
"enable": false,
"filter_pattern": ""
}
object({|
enable : bool
filter_pattern : string
destination_arn : string
})
{| no | | description | Lambda function description | `string` | `"Managed by Terraform"` | no | | environment | Lambda environment variables | `map(string)` | `null` | no | +| file\_name | Lambda function filename name | `string` | n/a | yes | +| function\_name | Lambda function name | `string` | n/a | yes | +| handler | Lambda function handler | `string` | n/a | yes | | layers | List of layers for this lambda function | `list(string)` | `[]` | no | -| memory_size | Lambda function memory size | `number` | `128` | no | +| memory\_size | Lambda function memory size | `number` | `128` | no | | publish | Publish lambda function | `bool` | `false` | no | -| reserved_concurrent_executions | Reserved concurrent executions for this lambda function | `number` | `-1` | no | +| region | AWS region | `string` | n/a | yes | +| reserved\_concurrent\_executions | Reserved concurrent executions for this lambda function | `number` | `-1` | no | +| role | Lambda function role | `string` | n/a | yes | | runtime | Lambda function runtime | `string` | `"nodejs12.x"` | no | | tags | Tags for this lambda function | `map(string)` | `{}` | no | | timeout | Lambda function runtime | `number` | `300` | no | -| tracing_config | https://www.terraform.io/docs/providers/aws/r/lambda_function.html |
"destination_arn": "",
"enable": false,
"filter_pattern": ""
}
object({|
mode : string
})
{| no | -| vpc_config | Lambda VPC configuration |
"mode": "PassThrough"
}
object({|
subnet_ids : list(string)
security_group_ids : list(string)
})
{| no | +| tracing\_config | https://www.terraform.io/docs/providers/aws/r/lambda_function.html |
"security_group_ids": [],
"subnet_ids": []
}
object({|
mode : string
})
{| no | +| trigger | Trigger configuration for this lambda function | `any` | n/a | yes | +| vpc\_config | Lambda VPC configuration |
"mode": "PassThrough"
}
object({|
subnet_ids : list(string)
security_group_ids : list(string)
})
{| no | ## Outputs @@ -56,10 +56,9 @@ MIT Licensed. See LICENSE for full details. |------|-------------| | arn | AWS lambda arn | | dlq | AWS lambda Dead Letter Queue details | -| function_name | AWS lambda function name | -| invoke_arn | AWS lambda invoke_arn | -| qualified_arn | AWS lambda qualified_arn | +| function\_name | AWS lambda function name | +| invoke\_arn | AWS lambda invoke\_arn | +| qualified\_arn | AWS lambda qualified\_arn | | queue | AWS lambda SQS details | -| sns_topics | AWS lambda SNS topics if any | +| sns\_topics | AWS lambda SNS topics if any | | version | AWS lambda version | - diff --git a/docker-compose.develop.yml b/docker-compose.develop.yml index d874eab..56dbbbb 100644 --- a/docker-compose.develop.yml +++ b/docker-compose.develop.yml @@ -5,10 +5,5 @@ services: command: bash volumes: - ./:/go/src/github.com/comtravo/terraform-aws-lambda - - localstack: - ports: - - 4566:4566 - - 4584-4597:4584-4597 - - 4567-4583:4567-4583 - - 8080:8080 + environment: + - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-foo} # automated infra testing acc creds diff --git a/docker-compose.yml b/docker-compose.yml index bc42228..5533b8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,25 +9,5 @@ services: environment: - AWS_REGION=us-east-1 - AWS_DEFAULT_REGION=us-east-1 - - AWS_ACCESS_KEY_ID=foo - - AWS_SECRET_ACCESS_KEY=bar - - LOCALSTACK_HOST=localstack - depends_on: - - localstack - - localstack: - image: localstack/localstack:0.11.4 - environment: - - SERVICES=events,iam,logs,lambda,sns,sqs,sts - - AWS_REGION=us-east-1 - - AWS_DEFAULT_REGION=us-east-1 - - DEFAULT_REGIONc=us-east-1 - - DOCKER_HOST=unix:///var/run/docker.sock - - DATA_DIR=/tmp/localstack/data - - DEBUG=1 - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - "localstack-data:/tmp/localstack" - -volumes: - localstack-data: + - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-foo} # automated infra testing acc creds + - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-foo} # automated infra testing acc creds diff --git a/examples/api_gateway_trigger/main.tf b/examples/api_gateway_trigger/main.tf index 45fef49..4ddb981 100644 --- a/examples/api_gateway_trigger/main.tf +++ b/examples/api_gateway_trigger/main.tf @@ -42,7 +42,7 @@ module "api_gatewat_trigger" { file_name = "${path.module}/../../test/fixtures/foo.zip" function_name = var.function_name handler = "index.handler" - role = aws_iam_role.lambda.name + role = aws_iam_role.lambda.arn trigger = { type = "api-gateway" } diff --git a/examples/cloudwatch_event_pattern_trigger/main.tf b/examples/cloudwatch_event_pattern_trigger/main.tf index 7747d6b..af4219b 100644 --- a/examples/cloudwatch_event_pattern_trigger/main.tf +++ b/examples/cloudwatch_event_pattern_trigger/main.tf @@ -42,10 +42,32 @@ module "cloudwatch_event_pattern_trigger" { file_name = "${path.module}/../../test/fixtures/foo.zip" function_name = var.function_name handler = "index.handler" - role = aws_iam_role.lambda.name + role = aws_iam_role.lambda.arn trigger = { - type = "cloudwatch-event-trigger" - schedule_expression = "{}" + type = "cloudwatch-event-trigger" + event_pattern = <
"security_group_ids": [],
"subnet_ids": []
}
object({| n/a | yes | | enable | Enable module | `bool` | `false` | no | +| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | +| schedule\_config | CloudWatch event schedule configuration |
name : string
description : string
schedule_expression : string
})
object({| n/a | yes | ## Outputs No output. - diff --git a/triggers/cloudwatch_event_schedule/versions.tf b/triggers/cloudwatch_event_schedule/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/cloudwatch_event_schedule/versions.tf +++ b/triggers/cloudwatch_event_schedule/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/triggers/cloudwatch_event_trigger/README.md b/triggers/cloudwatch_event_trigger/README.md index b66e698..3ae57f2 100644 --- a/triggers/cloudwatch_event_trigger/README.md +++ b/triggers/cloudwatch_event_trigger/README.md @@ -7,7 +7,7 @@ Allow this lambda to be triggered by Cloudwatch Event Trigger | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -20,11 +20,10 @@ Allow this lambda to be triggered by Cloudwatch Event Trigger | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| event_config | Cloudwatch event configuration |
name : string
description : string
schedule_expression : string
})
object({| n/a | yes | -| lambda_function_arn | Lambda function arn | `string` | n/a | yes | | enable | Enable module | `bool` | `false` | no | +| event\_config | Cloudwatch event configuration |
name : string
description : string
event_pattern : string
})
object({| n/a | yes | +| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | ## Outputs No output. - diff --git a/triggers/cloudwatch_event_trigger/versions.tf b/triggers/cloudwatch_event_trigger/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/cloudwatch_event_trigger/versions.tf +++ b/triggers/cloudwatch_event_trigger/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/triggers/cloudwatch_logs/README.md b/triggers/cloudwatch_logs/README.md index 14c24c7..9114f81 100644 --- a/triggers/cloudwatch_logs/README.md +++ b/triggers/cloudwatch_logs/README.md @@ -7,7 +7,7 @@ Allow this lambda to be triggered by Cloudwatch logs | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -20,11 +20,10 @@ Allow this lambda to be triggered by Cloudwatch logs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| lambda_function_arn | Lambda arn | `string` | n/a | yes | -| region | AWS region | `string` | n/a | yes | | enable | Enable module | `bool` | `false` | no | +| lambda\_function\_arn | Lambda arn | `string` | n/a | yes | +| region | AWS region | `string` | n/a | yes | ## Outputs No output. - diff --git a/triggers/cloudwatch_logs/versions.tf b/triggers/cloudwatch_logs/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/cloudwatch_logs/versions.tf +++ b/triggers/cloudwatch_logs/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/triggers/cognito_idp/README.md b/triggers/cognito_idp/README.md index 8850f94..a3e35d6 100644 --- a/triggers/cognito_idp/README.md +++ b/triggers/cognito_idp/README.md @@ -7,7 +7,7 @@ Allow this lambda to be triggered by Cognito IDP | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -20,10 +20,9 @@ Allow this lambda to be triggered by Cognito IDP | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| lambda_function_arn | Lambda function arn | `string` | n/a | yes | | enable | Enable module | `bool` | `false` | no | +| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | ## Outputs No output. - diff --git a/triggers/cognito_idp/versions.tf b/triggers/cognito_idp/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/cognito_idp/versions.tf +++ b/triggers/cognito_idp/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/triggers/sqs/README.md b/triggers/sqs/README.md index a2b54c8..ff205ff 100644 --- a/triggers/sqs/README.md +++ b/triggers/sqs/README.md @@ -7,7 +7,7 @@ Allow this lambda to be triggered by SQS and optionally subscribe to SNS topics | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -20,10 +20,10 @@ Allow this lambda to be triggered by SQS and optionally subscribe to SNS topics | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| lambda_function_arn | Lambda function arn | `string` | n/a | yes | -| sqs_config | SQS config |
name : string
description : string
event_pattern : string
})
object({| n/a | yes | -| tags | Tags | `map(string)` | n/a | yes | | enable | Enable module | `bool` | `false` | no | +| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | +| sqs\_config | SQS config |
sns_topics : list(string)
fifo : bool
sqs_name : string
visibility_timeout_seconds : number
batch_size : number
})
object({| n/a | yes | +| tags | Tags | `map(string)` | n/a | yes | ## Outputs @@ -31,6 +31,5 @@ Allow this lambda to be triggered by SQS and optionally subscribe to SNS topics |------|-------------| | dlq | Dead letter queue details | | queue | SQS queue details | -| queue_arn | SQS ARN | -| queue_id | SQS endpoint | - +| queue\_arn | SQS ARN | +| queue\_id | SQS endpoint | diff --git a/triggers/sqs/versions.tf b/triggers/sqs/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/sqs/versions.tf +++ b/triggers/sqs/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/triggers/step_function/README.md b/triggers/step_function/README.md index ede15c2..fbd59ac 100644 --- a/triggers/step_function/README.md +++ b/triggers/step_function/README.md @@ -7,7 +7,7 @@ Allow this lambda to be triggered by Step functions | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -20,11 +20,10 @@ Allow this lambda to be triggered by Step functions | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| lambda_function_arn | Lambda function arn | `string` | n/a | yes | -| region | AWS region | `string` | n/a | yes | | enable | Enable module | `bool` | `false` | no | +| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | +| region | AWS region | `string` | n/a | yes | ## Outputs No output. - diff --git a/triggers/step_function/versions.tf b/triggers/step_function/versions.tf index 58d8acb..181a96e 100644 --- a/triggers/step_function/versions.tf +++ b/triggers/step_function/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } } diff --git a/versions.tf b/versions.tf index f38861f..181a96e 100644 --- a/versions.tf +++ b/versions.tf @@ -1,8 +1,10 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { - aws = "~> 3.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } } - experiments = [variable_validation] }
sns_topics : list(string)
fifo : bool
sqs_name : string
visibility_timeout_seconds : number
batch_size : number
})