diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 0a52135..3b0f67b 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,6 +1,6 @@ name: 'Terraform GitHub Actions' on: - - pull_request + - push jobs: terraform: @@ -11,37 +11,74 @@ jobs: - name: 'Checkout' uses: actions/checkout@master - - name: 'Terraform Format' - uses: clouddrove/github-actions@v2.0 + - name: 'Terraform Format fmt' + uses: hashicorp/terraform-github-actions@master with: - actions_subcommand: 'fmt' + tf_actions_version: 0.13.3 + tf_actions_subcommand: 'fmt' + tf_actions_working_dir: "./_example/basic_example" + tf_actions_comment: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: 'Terraform Init' - uses: clouddrove/github-actions@v2.0 + - name: 'Terraform Format fmt' + uses: hashicorp/terraform-github-actions@master with: - actions_subcommand: 'init' - tf_actions_working_dir: ./_example + tf_actions_version: 0.13.3 + tf_actions_subcommand: 'fmt' + tf_actions_working_dir: "./_example/secure_example" + tf_actions_comment: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Configure AWS Credentials uses: clouddrove/configure-aws-credentials@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }} aws-region: us-east-2 - - name: 'Terraform Plan' - uses: clouddrove/github-actions@v2.0 + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Get dependencies + run: | + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + else + go get -v -t -d ./... + fi + + - name: Test Basic Example + working-directory: ./_test/basic_example + run: go test + + - name: Test Secure Example + working-directory: ./_test/secure_example + run: go test + + - name: 'Terraform Init Baic Example' + uses: hashicorp/terraform-github-actions@master with: - actions_subcommand: 'plan' - tf_actions_working_dir: ./_example + tf_actions_version: 0.13.3 + tf_actions_subcommand: 'init' + tf_actions_working_dir: "./_example/basic_example" + tf_actions_comment: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: 'Terratest' - uses: clouddrove/github-actions@v2.0 + - name: 'Terraform Init Secure Example' + uses: hashicorp/terraform-github-actions@master with: - actions_subcommand: 'terratest' - tf_actions_working_dir: ./_test + tf_actions_version: 0.13.3 + tf_actions_subcommand: 'init' + tf_actions_working_dir: "./_example/secure_example" + tf_actions_comment: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -53,5 +90,5 @@ jobs: author_name: 'Clouddrove' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required if: always() \ No newline at end of file diff --git a/LICENSE b/LICENSE index 136d77d..807110a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Cloud Drove +Copyright (c) 2020 Cloud Drove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.yaml b/README.yaml index ba3ceed..71b50da 100644 --- a/README.yaml +++ b/README.yaml @@ -16,7 +16,7 @@ github_repo: clouddrove/terraform-aws-ec2 # Badges to display badges: - name: "Terraform" - image: "https://img.shields.io/badge/Terraform-v0.12-green" + image: "https://img.shields.io/badge/Terraform-v0.13-green" url: "https://www.terraform.io" - name: "Licence" image: "https://img.shields.io/badge/License-MIT-blue.svg" @@ -36,7 +36,7 @@ usage : |- ### Basic Example ```hcl module "ec2" { - source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7" + source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.13.0" name = "ec2-instance" application = "clouddrove" environment = "test" @@ -66,7 +66,7 @@ usage : |- ### Secure Example ```hcl module "ec2" { - source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.12.7" + source = "git::https://github.com/clouddrove/terraform-aws-ec2.git?ref=tags/0.13.0" name = "ec2-instance" application = "clouddrove" environment = "test" diff --git a/_example/basic_example/example.tf b/_example/basic_example/example.tf index 5a6a0c4..5eb50fe 100644 --- a/_example/basic_example/example.tf +++ b/_example/basic_example/example.tf @@ -3,7 +3,7 @@ provider "aws" { } module "vpc" { - source = "git::https://github.com/clouddrove/terraform-aws-vpc.git?ref=tags/0.12.4" + source = "git::https://github.com/clouddrove/terraform-aws-vpc.git?ref=tags/0.13.0" name = "vpc" application = "clouddrove" @@ -14,7 +14,7 @@ module "vpc" { } module "public_subnets" { - source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4" + source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.8" name = "public-subnet" application = "clouddrove" @@ -26,10 +26,11 @@ module "public_subnets" { cidr_block = module.vpc.vpc_cidr_block type = "public" igw_id = module.vpc.igw_id + ipv6_cidr_block = module.vpc.ipv6_cidr_block } module "http-https" { - source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.3" + source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.5" name = "http-https" application = "clouddrove" @@ -42,7 +43,7 @@ module "http-https" { } module "ssh" { - source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.3" + source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.5" name = "ssh" application = "clouddrove" diff --git a/_example/secure_example/example.tf b/_example/secure_example/example.tf index 5e31b90..59b7515 100644 --- a/_example/secure_example/example.tf +++ b/_example/secure_example/example.tf @@ -3,7 +3,7 @@ provider "aws" { } module "vpc" { - source = "git::https://github.com/clouddrove/terraform-aws-vpc.git?ref=tags/0.12.4" + source = "git::https://github.com/clouddrove/terraform-aws-vpc.git?ref=tags/0.13.0" name = "vpc" application = "clouddrove" @@ -14,7 +14,7 @@ module "vpc" { } module "public_subnets" { - source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4" + source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.8" name = "public-subnet" application = "clouddrove" @@ -26,10 +26,11 @@ module "public_subnets" { cidr_block = module.vpc.vpc_cidr_block type = "public" igw_id = module.vpc.igw_id + ipv6_cidr_block = module.vpc.ipv6_cidr_block } module "http-https" { - source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.3" + source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.5" name = "http-https" application = "clouddrove" @@ -42,7 +43,7 @@ module "http-https" { } module "ssh" { - source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.3" + source = "git::https://github.com/clouddrove/terraform-aws-security-group.git?ref=tags/0.12.5" name = "ssh" application = "clouddrove" diff --git a/_test/basic_example/ec2_test.go b/_test/basic_example/ec2_test.go index 1371006..dc1f3b1 100644 --- a/_test/basic_example/ec2_test.go +++ b/_test/basic_example/ec2_test.go @@ -14,7 +14,7 @@ func Test(t *testing.T) { terraformOptions := &terraform.Options{ // Source path of Terraform directory. - TerraformDir: "../_example", + TerraformDir: "../../_example/basic_example", Upgrade: true, } diff --git a/_test/basic_example/go.mod b/_test/basic_example/go.mod new file mode 100644 index 0000000..a912351 --- /dev/null +++ b/_test/basic_example/go.mod @@ -0,0 +1,8 @@ +module github.com/clouddrove/terraform-aws-ec2/baisc_example + +go 1.13 + +require ( + github.com/gruntwork-io/terratest v0.30.6 + github.com/stretchr/testify v1.6.1 +) diff --git a/_test/secure_example/ec2_test.go b/_test/secure_example/ec2_test.go index 1371006..247a1ec 100644 --- a/_test/secure_example/ec2_test.go +++ b/_test/secure_example/ec2_test.go @@ -14,7 +14,7 @@ func Test(t *testing.T) { terraformOptions := &terraform.Options{ // Source path of Terraform directory. - TerraformDir: "../_example", + TerraformDir: "../../_example/secure_example", Upgrade: true, } diff --git a/_test/secure_example/go.mod b/_test/secure_example/go.mod new file mode 100644 index 0000000..c328511 --- /dev/null +++ b/_test/secure_example/go.mod @@ -0,0 +1,8 @@ +module github.com/clouddrove/terraform-aws-ec2/secure_example + +go 1.13 + +require ( + github.com/gruntwork-io/terratest v0.30.6 + github.com/stretchr/testify v1.6.1 +) diff --git a/main.tf b/main.tf index f9b0a8c..c8713aa 100644 --- a/main.tf +++ b/main.tf @@ -7,13 +7,14 @@ # tags for resources. You can use terraform-labels to implement a strict # naming convention. module "labels" { - source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0" + source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.13.0" name = var.name application = var.application environment = var.environment label_order = var.label_order managedby = var.managedby + enabled = var.instance_enabled } locals { diff --git a/versions.tf b/versions.tf index 5e90985..4849de3 100644 --- a/versions.tf +++ b/versions.tf @@ -1,4 +1,9 @@ # Terraform version terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" + required_providers { + aws = { + source = "hashicorp/aws" + } + } }