Skip to content

Commit 9c0ef1b

Browse files
goruhamilldrRoseSecurity
authored
Component testing guide (#733)
Co-authored-by: Dan Miller <miller0daniel@gmail.com> Co-authored-by: RoseSecurity <72598486+RoseSecurity@users.noreply.github.com>
1 parent 1378bc4 commit 9c0ef1b

File tree

10 files changed

+918
-1
lines changed

10 files changed

+918
-1
lines changed

docs/community/contribute/components-testing.mdx

Lines changed: 812 additions & 0 deletions
Large diffs are not rendered by default.

docs/layers/project/toolbox.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Geodesic is a powerful Linux toolbox container designed to optimize DevOps workf
4040
Build a Geodesic infrastructure container. This container that has all the tools like terraform and atmos for building infrastructure. It's built from the `Dockerfile` and there are some predefined targets defined in the `Makefile` to make this easy. Customize these for your organization. Here are examples of both for reference.
4141

4242
<CollapsibleText type="medium">
43-
<CodeBlock title="Dockerfile">{PartialDockerfile}</CodeBlock>
4443
</CollapsibleText>
4544

4645
<CollapsibleText type="medium">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
components:
2+
terraform:
3+
vpc:
4+
metadata:
5+
component: vpc
6+
vars:
7+
name: "vpc"
8+
availability_zones:
9+
- "b"
10+
- "c"
11+
public_subnets_enabled: true
12+
max_nats: 1
13+
# Private subnets do not need internet access
14+
nat_gateway_enabled: false
15+
nat_instance_enabled: false
16+
subnet_type_tag_key: "eg.cptest.co/subnet/type"
17+
max_subnet_count: 3
18+
vpc_flow_logs_enabled: false
19+
ipv4_primary_cidr_block: "172.16.0.0/16"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package test
2+
3+
import (
4+
"testing"
5+
6+
helper "github.com/cloudposse/test-helpers/pkg/atmos/component-helper"
7+
)
8+
9+
type ComponentSuite struct {
10+
helper.TestSuite
11+
}
12+
13+
func TestRunSuite(t *testing.T) {
14+
suite := new(ComponentSuite)
15+
16+
// Deploy the dependent vpc component
17+
suite.AddDependency(t, "vpc", "default-test", nil)
18+
19+
helper.Run(t, suite)
20+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import:
2+
- orgs/default/test/_defaults
3+
# Import the dependent component
4+
- catalog/vpc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: atmos/v1
2+
kind: AtmosVendorConfig
3+
metadata:
4+
name: fixtures
5+
description: Atmos vendoring manifest
6+
spec:
7+
sources:
8+
- component: "account-map"
9+
source: github.com/cloudposse/terraform-aws-components.git//modules/account-map?ref={{.Version}}
10+
version: 1.520.0
11+
targets:
12+
- "components/terraform/account-map"
13+
included_paths:
14+
- "**/*.tf"
15+
- "**/*.md"
16+
- "**/*.tftmpl"
17+
- "**/modules/**"
18+
excluded_paths: []
19+
20+
# Example of a dependency from vpc component
21+
- component: "vpc"
22+
source: github.com/cloudposse-terraform-components/aws-vpc.git//src?ref={{.Version}}
23+
version: v1.536.0
24+
# Specify the path to the component directory
25+
targets:
26+
- "components/terraform/vpc"
27+
included_paths:
28+
- "**/*.tf"
29+
- "**/*.md"
30+
- "**/*.tftmpl"
31+
- "**/modules/**"
32+
excluded_paths: []
33+
# Example of a dependency from vpc component
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import:
2+
- orgs/default/test/_defaults
3+
- catalog/vpc
4+
# Import the usecase
5+
- catalog/usecase/basic
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
components:
2+
terraform:
3+
# You can replace example-component with your component name
4+
example-component/basic:
5+
metadata:
6+
# Component name dir should be always `target`
7+
component: target
8+
vars:
9+
enabled: true
10+
# Add other inputs that are required for the use case
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import:
2+
- orgs/default/test/_defaults
3+
- catalog/vpc
4+
- catalog/usecase/basic
5+
# Import the "disabled" usecase
6+
- catalog/usecase/disabled
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
components:
2+
terraform:
3+
# You can replace example-component with your component name
4+
example-component/disabled:
5+
metadata:
6+
component: target
7+
vars:
8+
# Disable the component
9+
enabled: false

0 commit comments

Comments
 (0)