diff --git a/Dockerfile b/Dockerfile index 5c8f90f..bad6311 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-firehose COPY . . diff --git a/Jenkinsfile b/Jenkinsfile index 5f949fc..d21adfa 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") } diff --git a/Makefile b/Makefile index 70180ac..ef26337 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,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 table . > README.md +GENERATE_DOCS_COMMAND:=terraform-docs markdown . > README.md fmt: @terraform fmt -recursive @@ -16,7 +16,6 @@ build: @$(DOCKER_COMPOSE) build test: - @cd tests && go test -v -tags=unit @cd tests && go test -v -tags=integration test-docker: diff --git a/README.md b/README.md index e223c99..e30854b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ MIT Licensed. See [LICENSE](LICENSE) for full details. | Name | Version | |------|---------| -| terraform | >= 0.12 | +| terraform | >= 0.13 | | aws | ~> 3.0 | ## Providers @@ -33,15 +33,14 @@ MIT Licensed. See [LICENSE](LICENSE) for full details. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | account\_id | AWS account ID | `string` | n/a | yes | -| name | Name of the firehose | `string` | n/a | yes | -| s3\_configuration | AWS S3 configuration |
object({
bucket_arn = string,
buffer_interval = number,
buffer_size = number,
prefix = string
})
| n/a | yes | | destination | Kinesis Firehose Destination | `string` | `"s3"` | no | | enable | Enable firehose | `bool` | `true` | no | +| name | Name of the firehose | `string` | n/a | yes | | region | AWS region | `string` | `"eu-west-1"` | no | +| s3\_configuration | AWS S3 configuration |
object({
bucket_arn = string,
buffer_interval = number,
buffer_size = number,
prefix = string
})
| n/a | yes | ## Outputs | Name | Description | |------|-------------| | arn | ARN of the Kinesis Firehose | - diff --git a/docker-compose.develop.yml b/docker-compose.develop.yml index 481f5f1..cc35ecd 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-firehose - - localstack: - ports: - - 4566:4566 - - 4584-4597:4584-4597 - - 4567-4583:4567-4583 - - 8080:8080 + environment: + - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} diff --git a/docker-compose.yml b/docker-compose.yml index aec16bd..2bddd63 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,22 +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=s3,firehose,iam,sts - - DEFAULT_REGION=us-east-1 - - DOCKER_HOST=unix:///var/run/docker.sock - - DATA_DIR=/tmp/localstack/data - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - "localstack-data:/tmp/localstack" - -volumes: - localstack-data: + - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} diff --git a/tests/firehose_integration_test.go b/tests/firehose_integration_test.go index 36a3467..a6182e8 100644 --- a/tests/firehose_integration_test.go +++ b/tests/firehose_integration_test.go @@ -1,12 +1,14 @@ - // +build integration package test import ( + "fmt" + "regexp" + "testing" + "github.com/gruntwork-io/terratest/modules/terraform" "github.com/stretchr/testify/assert" - "testing" ) func TestFirehoseApply(t *testing.T) { @@ -19,11 +21,14 @@ func TestFirehoseApply(t *testing.T) { defer terraform.Destroy(t, terratestOptions) output := terraform.InitAndApply(t, terratestOptions) - assert.Contains(t, output, "Apply complete! Resources: 4 added, 0 changed, 0 destroyed.") + assert.Contains(t, output, "Apply complete! Resources: 5 added, 0 changed, 0 destroyed.") firehose_disabled_output := terraform.Output(t, terratestOptions, "firehose_disabled") assert.Equal(t, firehose_disabled_output, "") firehose_enabled_output := terraform.Output(t, terratestOptions, "firehose_enabled") - assert.Equal(t, firehose_enabled_output, "arn:aws:firehose:us-east-1:000000000000:deliverystream/firehose_enabled") + assert.Regexp(t, + regexp.MustCompile(fmt.Sprintf("arn:aws:firehose:us-east-1:\\d{12}:deliverystream/firehose_enabled")), + firehose_enabled_output, + ) } diff --git a/tests/firehose_unit_test.go b/tests/firehose_unit_test.go deleted file mode 100644 index cedde68..0000000 --- a/tests/firehose_unit_test.go +++ /dev/null @@ -1,24 +0,0 @@ - -// +build unit - -package test - -import ( - "github.com/gruntwork-io/terratest/modules/terraform" - "github.com/stretchr/testify/assert" - "testing" -) - -func TestFirehosePlan(t *testing.T) { - - terratestOptions := &terraform.Options{ - TerraformDir: ".", - Vars: map[string]interface{}{}, - } - - defer terraform.Destroy(t, terratestOptions) - - output := terraform.InitAndPlan(t, terratestOptions) - - assert.Contains(t, output, "4 to add, 0 to change, 0 to destroy.") -} diff --git a/tests/test.tf b/tests/test.tf index bc43cc1..36df344 100644 --- a/tests/test.tf +++ b/tests/test.tf @@ -1,39 +1,14 @@ provider "aws" { - s3_force_path_style = true - skip_credentials_validation = true - skip_metadata_api_check = true - skip_requesting_account_id = true - access_key = "This is not an actual access key." - secret_key = "This is not an actual secret key." +} - endpoints { - apigateway = "http://localstack:4567" - cloudformation = "http://localstack:4581" - cloudwatch = "http://localstack:4582" - dynamodb = "http://localstack:4569" - es = "http://localstack:4578" - firehose = "http://localstack:4573" - iam = "http://localstack:4593" - kinesis = "http://localstack:4568" - lambda = "http://localstack:4574" - route53 = "http://localstack:4580" - redshift = "http://localstack:4577" - s3 = "http://localstack:4572" - secretsmanager = "http://localstack:4584" - ses = "http://localstack:4579" - sns = "http://localstack:4575" - sqs = "http://localstack:4576" - ssm = "http://localstack:4583" - stepfunctions = "http://localstack:4585" - sts = "http://localstack:4592" - } +resource "random_pet" "s3_bucket" { } data "aws_caller_identity" "current" {} data "aws_region" "current" {} resource "aws_s3_bucket" "b" { - bucket = "my-tf-test-bucket" + bucket = "ct-firehose-test-${random_pet.s3_bucket.id}" acl = "private" } diff --git a/versions.tf b/versions.tf index 58d8acb..181a96e 100644 --- a/versions.tf +++ b/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" + } } }