Skip to content

Commit 90ca5cf

Browse files
authored
Add codefresh (#57)
* Add tests * Update README
1 parent f5cefb4 commit 90ca5cf

File tree

19 files changed

+395
-8
lines changed

19 files changed

+395
-8
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Cloud Posse][logo]](https://cpco.io/homepage)
55

6-
# terraform-aws-dynamic-subnets [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-dynamic-subnets.svg)](https://github.com/cloudposse/terraform-aws-dynamic-subnets/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
6+
# terraform-aws-dynamic-subnets [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/cloudposse%2Fterraform-aws-dynamic-subnets%2Ftest?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/cloudposse/terraform-aws-dynamic-subnets/test) [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-dynamic-subnets.svg)](https://github.com/cloudposse/terraform-aws-dynamic-subnets/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
77

88

99
Terraform module to provision public and private [`subnets`](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html) in an existing [`VPC`](https://aws.amazon.com/vpc)
@@ -53,6 +53,9 @@ Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest re
5353
```hcl
5454
module "subnets" {
5555
source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master"
56+
providers = {
57+
aws = "aws"
58+
}
5659
namespace = "cp"
5760
stage = "prod"
5861
name = "app"
@@ -64,6 +67,8 @@ module "subnets" {
6467
}
6568
```
6669

70+
Learn about [using providers](https://www.terraform.io/docs/configuration-0-11/modules.html#providers-within-modules) with terraform modules.
71+
6772

6873

6974

@@ -174,7 +179,6 @@ Available targets:
174179
| private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no |
175180
| public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no |
176181
| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no |
177-
| region | AWS Region (e.g. `us-east-1`) | string | - | yes |
178182
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no |
179183
| subnet_type_tag_key | Key for subnet type tag to provide information about the type of subnets, e.g. `cpco.io/subnet/type=private` or `cpco.io/subnet/type=public` | string | `cpco.io/subnet/type` | no |
180184
| subnet_type_tag_value_format | This is using the format interpolation symbols to allow the value of the subnet_type_tag_key to be modified. | string | `%s` | no |

README.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ github_repo: cloudposse/terraform-aws-dynamic-subnets
3232

3333
# Badges to display
3434
badges:
35+
- name: "Codefresh Build Status"
36+
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/cloudposse%2Fterraform-aws-dynamic-subnets%2Ftest?type=cf-1"
37+
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/cloudposse/terraform-aws-dynamic-subnets/test"
3538
- name: "Build Status"
3639
image: "https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets.svg?branch=master"
3740
url: "https://travis-ci.org/cloudposse/terraform-aws-dynamic-subnets"
@@ -68,6 +71,9 @@ usage: |-
6871
```hcl
6972
module "subnets" {
7073
source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master"
74+
providers = {
75+
aws = "aws"
76+
}
7177
namespace = "cp"
7278
stage = "prod"
7379
name = "app"
@@ -79,6 +85,8 @@ usage: |-
7985
}
8086
```
8187
88+
Learn about [using providers](https://www.terraform.io/docs/configuration-0-11/modules.html#providers-within-modules) with terraform modules.
89+
8290
include:
8391
- "docs/design.md"
8492
- "docs/targets.md"
@@ -102,3 +110,4 @@ contributors:
102110
github: "ivan-pinatti"
103111
- name: "Oscar Sullivan"
104112
github: "osulli"
113+

codefresh/test.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
version: '1.0'
2+
3+
stages:
4+
- Prepare
5+
- Test
6+
7+
steps:
8+
wait:
9+
title: Wait
10+
stage: Prepare
11+
image: codefresh/cli:latest
12+
commands:
13+
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
14+
retry:
15+
maxAttempts: 10
16+
delay: 20
17+
exponentialFactor: 1.1
18+
19+
main_clone:
20+
title: "Clone repository"
21+
type: git-clone
22+
stage: Prepare
23+
description: "Initialize"
24+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
25+
git: CF-default
26+
revision: ${{CF_REVISION}}
27+
28+
clean_init:
29+
title: Prepare build-harness and test-harness
30+
image: ${{TEST_IMAGE}}
31+
stage: Prepare
32+
commands:
33+
- cf_export PATH="/usr/local/terraform/0.11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
34+
- make init
35+
- git -C build-harness checkout master
36+
- make -C test/ clean init TEST_HARNESS_BRANCH=master
37+
- make -C test/src clean init
38+
- find test/src -name '*.tf' -delete
39+
40+
test:
41+
type: "parallel"
42+
title: "Run tests"
43+
description: "Run all tests in parallel"
44+
stage: Test
45+
steps:
46+
test_readme_lint:
47+
title: "Test README.md updated"
48+
stage: "Test"
49+
image: ${{TEST_IMAGE}}
50+
description: Test "readme/lint"
51+
commands:
52+
- make readme/lint
53+
54+
test_module:
55+
title: Test module with bats
56+
image: ${{TEST_IMAGE}}
57+
stage: Test
58+
commands:
59+
- make -C test/ module
60+
61+
test_examples_complete:
62+
title: Test "examples/complete" with bats
63+
image: ${{TEST_IMAGE}}
64+
stage: Test
65+
commands:
66+
- make -C test/ examples/complete
67+
68+
test_examples_complete_terratest:
69+
title: Test "examples/complete" with terratest
70+
image: ${{TEST_IMAGE}}
71+
stage: Test
72+
commands:
73+
- make -C test/src

docs/terraform.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
| private_network_acl_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | string | `` | no |
2222
| public_network_acl_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | string | `` | no |
2323
| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no |
24-
| region | AWS Region (e.g. `us-east-1`) | string | - | yes |
2524
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no |
2625
| subnet_type_tag_key | Key for subnet type tag to provide information about the type of subnets, e.g. `cpco.io/subnet/type=private` or `cpco.io/subnet/type=public` | string | `cpco.io/subnet/type` | no |
2726
| subnet_type_tag_value_format | This is using the format interpolation symbols to allow the value of the subnet_type_tag_key to be modified. | string | `%s` | no |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
max_availability_zones = 2
2+
3+
region = "us-west-1"
4+
5+
availability_zones = ["us-west-1b", "us-west-1c"]
6+
7+
namespace = "eg"
8+
9+
name = "vpc"
10+
11+
stage = "test"

examples/complete/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module "vpc" {
2+
source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.3.4"
3+
4+
providers = {
5+
aws = "aws"
6+
}
7+
8+
namespace = "${var.namespace}"
9+
stage = "${var.stage}"
10+
name = "${var.name}"
11+
cidr_block = "172.16.0.0/16"
12+
}
13+
14+
module "subnets" {
15+
source = "../../"
16+
17+
providers = {
18+
aws = "aws"
19+
}
20+
21+
availability_zones = "${var.availability_zones}"
22+
namespace = "${var.namespace}"
23+
stage = "${var.stage}"
24+
name = "${var.name}"
25+
vpc_id = "${module.vpc.vpc_id}"
26+
igw_id = "${module.vpc.igw_id}"
27+
cidr_block = "${module.vpc.vpc_cidr_block}"
28+
nat_gateway_enabled = "true"
29+
}

examples/complete/outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "public_subnet_cidrs" {
2+
value = "${module.subnets.public_subnet_cidrs}"
3+
}
4+
5+
output "private_subnet_cidrs" {
6+
value = "${module.subnets.private_subnet_cidrs}"
7+
}

examples/complete/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = "${var.region}"
3+
}

examples/complete/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
variable "max_availability_zones" {}
2+
3+
variable "region" {}
4+
5+
variable "availability_zones" {
6+
type = "list"
7+
}
8+
9+
variable "namespace" {}
10+
11+
variable "name" {}
12+
13+
variable "stage" {}

examples/complete/versions.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = "~> 0.11.7"
3+
}

0 commit comments

Comments
 (0)