Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
812 changes: 812 additions & 0 deletions docs/community/contribute/components-testing.mdx

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/layers/project/toolbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Geodesic is a powerful Linux toolbox container designed to optimize DevOps workf
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.

<CollapsibleText type="medium">
<CodeBlock title="Dockerfile">{PartialDockerfile}</CodeBlock>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we deleting this?

</CollapsibleText>

<CollapsibleText type="medium">
Expand Down
19 changes: 19 additions & 0 deletions examples/components-testing/step-3/catalog-vpc.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename folder to component-testing rather than components-testing

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
components:
terraform:
vpc:
metadata:
component: vpc
vars:
name: "vpc"
availability_zones:
- "b"
- "c"
public_subnets_enabled: true
max_nats: 1
# Private subnets do not need internet access
nat_gateway_enabled: false
nat_instance_enabled: false
subnet_type_tag_key: "eg.cptest.co/subnet/type"
max_subnet_count: 3
vpc_flow_logs_enabled: false
ipv4_primary_cidr_block: "172.16.0.0/16"
20 changes: 20 additions & 0 deletions examples/components-testing/step-3/component_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package test

import (
"testing"

helper "github.com/cloudposse/test-helpers/pkg/atmos/component-helper"
)

type ComponentSuite struct {
helper.TestSuite
}

func TestRunSuite(t *testing.T) {
suite := new(ComponentSuite)

// Deploy the dependent vpc component
suite.AddDependency(t, "vpc", "default-test", nil)

helper.Run(t, suite)
}
4 changes: 4 additions & 0 deletions examples/components-testing/step-3/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import:
- orgs/default/test/_defaults
# Import the dependent component
- catalog/vpc
33 changes: 33 additions & 0 deletions examples/components-testing/step-3/vendor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
name: fixtures
description: Atmos vendoring manifest
spec:
sources:
- component: "account-map"
source: github.com/cloudposse/terraform-aws-components.git//modules/account-map?ref={{.Version}}
version: 1.520.0
targets:
- "components/terraform/account-map"
included_paths:
- "**/*.tf"
- "**/*.md"
- "**/*.tftmpl"
- "**/modules/**"
excluded_paths: []

# Example of a dependency from vpc component
- component: "vpc"
source: github.com/cloudposse-terraform-components/aws-vpc.git//src?ref={{.Version}}
version: v1.536.0
# Specify the path to the component directory
targets:
- "components/terraform/vpc"
included_paths:
- "**/*.tf"
- "**/*.md"
- "**/*.tftmpl"
- "**/modules/**"
excluded_paths: []
# Example of a dependency from vpc component
5 changes: 5 additions & 0 deletions examples/components-testing/step-4/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import:
- orgs/default/test/_defaults
- catalog/vpc
# Import the usecase
- catalog/usecase/basic
10 changes: 10 additions & 0 deletions examples/components-testing/step-4/usecase.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to use-case.yaml

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
components:
terraform:
# You can replace example-component with your component name
example-component/basic:
metadata:
# Component name dir should be always `target`
component: target
vars:
enabled: true
# Add other inputs that are required for the use case
6 changes: 6 additions & 0 deletions examples/components-testing/step-7/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import:
- orgs/default/test/_defaults
- catalog/vpc
- catalog/usecase/basic
# Import the "disabled" usecase
- catalog/usecase/disabled
9 changes: 9 additions & 0 deletions examples/components-testing/step-7/usecase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
components:
terraform:
# You can replace example-component with your component name
example-component/disabled:
metadata:
component: target
vars:
# Disable the component
enabled: false
Loading