-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (#5)
* Convert to TF 0.12 * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline
- Loading branch information
Showing
29 changed files
with
597 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
.build-harness | ||
build-harness | ||
.terraform | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
.idea | ||
|
||
**/node_modules/* | ||
**/package-lock.json | ||
|
||
.build-harness | ||
build-harness | ||
|
||
*.zip | ||
|
||
*.iml | ||
.viminfo | ||
.terraform.d | ||
.idea |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
version: '1.0' | ||
|
||
stages: | ||
- Prepare | ||
- Test | ||
|
||
steps: | ||
wait: | ||
title: Wait | ||
stage: Prepare | ||
image: codefresh/cli:latest | ||
commands: | ||
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' | ||
retry: | ||
maxAttempts: 10 | ||
delay: 20 | ||
exponentialFactor: 1.1 | ||
|
||
main_clone: | ||
title: "Clone repository" | ||
type: git-clone | ||
stage: Prepare | ||
description: "Initialize" | ||
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} | ||
git: CF-default | ||
revision: ${{CF_REVISION}} | ||
|
||
clean_init: | ||
title: Prepare build-harness and test-harness | ||
image: ${{TEST_IMAGE}} | ||
stage: Prepare | ||
commands: | ||
- cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
- make init | ||
- git -C build-harness checkout master | ||
- make -C test/ clean init TEST_HARNESS_BRANCH=master | ||
- make -C test/src clean init | ||
- find . -type d -name '.terraform' | xargs rm -rf | ||
- find . -type f -name 'terraform.tfstate*' -exec rm -f {} \; | ||
|
||
test: | ||
type: "parallel" | ||
title: "Run tests" | ||
description: "Run all tests in parallel" | ||
stage: Test | ||
steps: | ||
test_readme_lint: | ||
title: "Test README.md updated" | ||
stage: "Test" | ||
image: ${{TEST_IMAGE}} | ||
description: Test "readme/lint" | ||
commands: | ||
- make readme/lint | ||
|
||
test_module: | ||
title: Test module with bats | ||
image: ${{TEST_IMAGE}} | ||
stage: Test | ||
commands: | ||
- make -C test/ module | ||
|
||
test_examples_complete: | ||
title: Test "examples/complete" with bats | ||
image: ${{TEST_IMAGE}} | ||
stage: Test | ||
commands: | ||
- make -C test/ examples/complete | ||
|
||
test_examples_complete_terratest: | ||
title: Test "examples/complete" with terratest | ||
image: ${{TEST_IMAGE}} | ||
stage: Test | ||
commands: | ||
- unset AWS_PROFILE | ||
- unset AWS_DEFAULT_PROFILE | ||
- unset AWS_MFA_PROFILE | ||
- make -C test/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
**/node_modules/* | ||
**/package-lock.json | ||
|
||
.build-harness | ||
build-harness | ||
|
||
*.zip | ||
|
||
*.iml | ||
.idea |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
region = "us-east-2" | ||
|
||
filename = "lambda.zip" | ||
|
||
module_name = "terraform-external-module-artifact" | ||
|
||
git_ref = "" | ||
|
||
url = "https://artifacts.cloudposse.com/terraform-external-module-artifact/example/test.zip" | ||
|
||
curl_arguments = "-fsSL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
module "external_module_artifact" { | ||
source = "../../" | ||
filename = var.filename | ||
module_name = var.module_name | ||
module_path = path.module | ||
url = var.url | ||
git_ref = var.git_ref | ||
curl_arguments = var.curl_arguments | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "git_ref" { | ||
description = "Git commit hash corresponding to the artifact" | ||
value = module.external_module_artifact.git_ref | ||
} | ||
|
||
output "file" { | ||
description = "Full path to the locally downloaded file" | ||
value = module.external_module_artifact.file | ||
} | ||
|
||
output "url" { | ||
description = "URL corresponding to the artifact" | ||
value = module.external_module_artifact.url | ||
} | ||
|
||
output "base64sha256" { | ||
description = "Base64 encoded SHA256 hash of the local file" | ||
value = module.external_module_artifact.base64sha256 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
variable "region" { | ||
type = string | ||
description = "AWS Region" | ||
} | ||
|
||
variable "filename" { | ||
type = string | ||
description = "Artifact filename" | ||
} | ||
|
||
variable "module_name" { | ||
type = string | ||
description = "Name of the terraform module" | ||
} | ||
|
||
variable "git_ref" { | ||
type = string | ||
description = "Git hash corresponding to the remote artifact. Leave blank and it will be computed from the `module_path` checkout" | ||
default = "" | ||
} | ||
|
||
variable "url" { | ||
type = string | ||
description = "URL template for the remote artifact" | ||
default = "https://artifacts.cloudposse.com/$$${module_name}/$$${git_ref}/$$${filename}" | ||
} | ||
|
||
variable "curl_arguments" { | ||
type = string | ||
description = "Arguments that should get passed to `curl`" | ||
default = "-fsSL" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = "~> 0.12.0" | ||
|
||
required_providers { | ||
aws = "~> 2.0" | ||
template = "~> 2.0" | ||
local = "~> 1.3" | ||
external = "~> 1.2" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
data "external" "curl" { | ||
program = ["curl", "${var.curl_arguments}", "--write-out", "{\"success\": \"true\", \"filename_effective\": \"%{filename_effective}\"}", "-o", "${local.output_file}", "${local.url}"] | ||
program = ["curl", var.curl_arguments, "--write-out", "{\"success\": \"true\", \"filename_effective\": \"%%{filename_effective}\"}", "-o", local.output_file, local.url] | ||
} | ||
|
||
data "external" "git" { | ||
count = "${var.git_ref == "" ? 1 : 0}" | ||
program = ["git", "-C", "${var.module_path}", "log", "-n", "1", "--pretty=format:{\"ref\": \"%H\"}"] | ||
count = var.git_ref == "" ? 1 : 0 | ||
program = ["git", "-C", var.module_path, "log", "-n", "1", "--pretty=format:{\"ref\": \"%H\"}"] | ||
} | ||
|
||
locals { | ||
external_curl_filename_effective = "${data.external.curl.result.filename_effective}" | ||
external_git_ref = "${join("", data.external.git.*.result.ref)}" | ||
git_ref = "${var.git_ref == "" ? local.external_git_ref : var.git_ref}" | ||
} | ||
|
||
locals { | ||
output_file = "${join("/", list(var.module_path, var.filename))}" | ||
external_curl_filename_effective = data.external.curl.result.filename_effective | ||
external_git_ref = join("", data.external.git.*.result.ref) | ||
git_ref = var.git_ref == "" ? local.external_git_ref : var.git_ref | ||
output_file = join("/", [var.module_path, var.filename]) | ||
url = data.template_file.url.rendered | ||
} | ||
|
||
data "template_file" "url" { | ||
template = "${replace(var.url, "$$$$", "$")}" | ||
template = replace(var.url, "$$", "$") | ||
|
||
vars { | ||
filename = "${var.filename}" | ||
git_ref = "${local.git_ref}" | ||
module_name = "${var.module_name}" | ||
vars = { | ||
filename = var.filename | ||
git_ref = local.git_ref | ||
module_name = var.module_name | ||
} | ||
} | ||
|
||
locals { | ||
url = "${data.template_file.url.rendered}" | ||
} |
Oops, something went wrong.