diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 9ff2bb8..a52c44b 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -49,5 +49,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' + expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" diff --git a/components/terraform/test/main.tf b/components/terraform/test/main.tf deleted file mode 100644 index d25a48e..0000000 --- a/components/terraform/test/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -variable "seed" { - type = string - default = "foo" -} - -resource "random_id" "this" { - keepers = { - # Generate a new id each time we switch to a new seed - seed = "${var.seed}" - } - byte_length = 8 -} diff --git a/tests/components/terraform/test/atmos.yaml b/tests/components/terraform/test/atmos.yaml deleted file mode 100644 index e9c4330..0000000 --- a/tests/components/terraform/test/atmos.yaml +++ /dev/null @@ -1,266 +0,0 @@ -# CLI config is loaded from the following locations (from lowest to highest priority): -# system dir ('/usr/local/etc/atmos' on Linux, '%LOCALAPPDATA%/atmos' on Windows) -# home dir (~/.atmos) -# current directory -# ENV vars -# Command-line arguments -# -# It supports POSIX-style Globs for file names/paths (double-star '**' is supported) -# https://en.wikipedia.org/wiki/Glob_(programming) - -# Base path for components, stacks and workflows configurations. -# Can also be set using 'ATMOS_BASE_PATH' ENV var, or '--base-path' command-line argument. -# Supports both absolute and relative paths. -# If not provided or is an empty string, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path' -# are independent settings (supporting both absolute and relative paths). -# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path' -# are considered paths relative to 'base_path'. -base_path: "./tests" - -components: - terraform: - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_BASE_PATH' ENV var, or '--terraform-dir' command-line argument - # Supports both absolute and relative paths - base_path: "components/terraform" - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE' ENV var - apply_auto_approve: false - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT' ENV var, or '--deploy-run-init' command-line argument - deploy_run_init: true - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE' ENV var, or '--init-run-reconfigure' command-line argument - init_run_reconfigure: true - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE' ENV var, or '--auto-generate-backend-file' command-line argument - auto_generate_backend_file: false - helmfile: - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_BASE_PATH' ENV var, or '--helmfile-dir' command-line argument - # Supports both absolute and relative paths - base_path: "components/helmfile" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_USE_EKS' ENV var - # If not specified, defaults to 'true' - use_eks: true - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH' ENV var - kubeconfig_path: "/dev/shm" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN' ENV var - helm_aws_profile_pattern: "{namespace}-gbl-{stage}-helm" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN' ENV var - cluster_name_pattern: "{namespace}-{environment}-{stage}-eks-cluster" - -stacks: - # Can also be set using 'ATMOS_STACKS_BASE_PATH' ENV var, or '--config-dir' and '--stacks-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks" - # Can also be set using 'ATMOS_STACKS_INCLUDED_PATHS' ENV var (comma-separated values string) - included_paths: - - "orgs/**/*" - # Can also be set using 'ATMOS_STACKS_EXCLUDED_PATHS' ENV var (comma-separated values string) - excluded_paths: - - "**/_defaults.yaml" - # Can also be set using 'ATMOS_STACKS_NAME_PATTERN' ENV var - name_pattern: "{tenant}-{environment}-{stage}" - -workflows: - # Can also be set using 'ATMOS_WORKFLOWS_BASE_PATH' ENV var, or '--workflows-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/workflows" - -logs: - verbose: false - colors: true - -# Custom CLI commands -commands: - - name: tf - description: Execute 'terraform' commands - # subcommands - commands: - - name: plan - description: This command plans terraform components - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - env: - - key: ENV_VAR_1 - value: ENV_VAR_1_value - - key: ENV_VAR_2 - # 'valueCommand' is an external command to execute to get the value for the ENV var - # Either 'value' or 'valueCommand' can be specified for the ENV var, but not both - valueCommand: echo ENV_VAR_2_value - # steps support Go templates - steps: - - atmos terraform plan {{ .Arguments.component }} -s {{ .Flags.stack }} - - name: terraform - description: Execute 'terraform' commands - # subcommands - commands: - - name: provision - description: This command provisions terraform components - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - # ENV var values support Go templates - env: - - key: ATMOS_COMPONENT - value: "{{ .Arguments.component }}" - - key: ATMOS_STACK - value: "{{ .Flags.stack }}" - steps: - - atmos terraform plan $ATMOS_COMPONENT -s $ATMOS_STACK - - atmos terraform apply $ATMOS_COMPONENT -s $ATMOS_STACK - - name: play - description: This command plays games - steps: - - echo Playing... - # subcommands - commands: - - name: hello - description: This command says Hello world - steps: - - echo Hello world - - name: ping - description: This command plays ping-pong - # If 'verbose' is set to 'true', atmos will output some info messages to the console before executing the command's steps - # If 'verbose' is not defined, it implicitly defaults to 'false' - verbose: true - steps: - - echo Playing ping-pong... - - echo pong - - name: show - description: Execute 'show' commands - # subcommands - commands: - - name: component - description: Execute 'show component' command - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - # ENV var values support Go templates and have access to {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables - env: - - key: ATMOS_COMPONENT - value: "{{ .Arguments.component }}" - - key: ATMOS_STACK - value: "{{ .Flags.stack }}" - - key: ATMOS_TENANT - value: "{{ .ComponentConfig.vars.tenant }}" - - key: ATMOS_STAGE - value: "{{ .ComponentConfig.vars.stage }}" - - key: ATMOS_ENVIRONMENT - value: "{{ .ComponentConfig.vars.environment }}" - - key: ATMOS_IS_PROD - value: "{{ .ComponentConfig.settings.config.is_prod }}" - # If a custom command defines 'component_config' section with 'component' and 'stack', 'atmos' generates the config for the component in the stack - # and makes it available in {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables, - # exposing all the component sections (which are also shown by 'atmos describe component' command) - component_config: - component: "{{ .Arguments.component }}" - stack: "{{ .Flags.stack }}" - # Steps support using Go templates and can access all configuration settings (e.g. {{ .ComponentConfig.xxx.yyy.zzz }}) - # Steps also have access to the ENV vars defined in the 'env' section of the 'command' - steps: - - 'echo Atmos component from argument: "{{ .Arguments.component }}"' - - 'echo ATMOS_COMPONENT: "$ATMOS_COMPONENT"' - - 'echo Atmos stack: "{{ .Flags.stack }}"' - - 'echo Terraform component: "{{ .ComponentConfig.component }}"' - - 'echo Backend S3 bucket: "{{ .ComponentConfig.backend.bucket }}"' - - 'echo Terraform workspace: "{{ .ComponentConfig.workspace }}"' - - 'echo Namespace: "{{ .ComponentConfig.vars.namespace }}"' - - 'echo Tenant: "{{ .ComponentConfig.vars.tenant }}"' - - 'echo Environment: "{{ .ComponentConfig.vars.environment }}"' - - 'echo Stage: "{{ .ComponentConfig.vars.stage }}"' - - 'echo settings.spacelift.workspace_enabled: "{{ .ComponentConfig.settings.spacelift.workspace_enabled }}"' - - 'echo Dependencies: "{{ .ComponentConfig.deps }}"' - - 'echo settings.config.is_prod: "{{ .ComponentConfig.settings.config.is_prod }}"' - - 'echo ATMOS_IS_PROD: "$ATMOS_IS_PROD"' - -# Integrations -integrations: - # Atlantis integration - # https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html - atlantis: - # Path and name of the Atlantis config file 'atlantis.yaml' - # Supports absolute and relative paths - # All the intermediate folders will be created automatically (e.g. 'path: /config/atlantis/atlantis.yaml') - # Can be overridden on the command line by using '--output-path' command-line argument in 'atmos atlantis generate repo-config' command - # If not specified (set to an empty string/omitted here, and set to an empty string on the command line), the content of the file will be dumped to 'stdout' - # On Linux/macOS, you can also use '--output-path=/dev/stdout' to dump the content to 'stdout' without setting it to an empty string in 'atlantis.path' - path: "atlantis.yaml" - - # Config templates - # Select a template by using the '--config-template ' command-line argument in 'atmos atlantis generate repo-config' command - config_templates: - config-1: - version: 3 - automerge: true - delete_source_branch_on_merge: true - parallel_plan: true - parallel_apply: true - allowed_regexp_prefixes: - - dev/ - - staging/ - - prod/ - - # Project templates - # Select a template by using the '--project-template ' command-line argument in 'atmos atlantis generate repo-config' command - project_templates: - project-1: - # generate a project entry for each component in every stack - name: "{tenant}-{environment}-{stage}-{component}" - workspace: "{workspace}" - dir: "{component-path}" - terraform_version: v1.2 - delete_source_branch_on_merge: true - autoplan: - enabled: true - when_modified: - - "**/*.tf" - - "varfiles/$PROJECT_NAME.tfvars.json" - apply_requirements: - - "approved" - - # Workflow templates - # https://www.runatlantis.io/docs/custom-workflows.html#custom-init-plan-apply-commands - # https://www.runatlantis.io/docs/custom-workflows.html#custom-run-command - # Select a template by using the '--workflow-template ' command-line argument in 'atmos atlantis generate repo-config' command - workflow_templates: - workflow-1: - plan: - steps: - - run: terraform init -input=false - # When using workspaces, you need to select the workspace using the $WORKSPACE environment variable - - run: terraform workspace select $WORKSPACE || terraform workspace new $WORKSPACE - # You must output the plan using '-out $PLANFILE' because Atlantis expects plans to be in a specific location - - run: terraform plan -input=false -refresh -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars.json - apply: - steps: - - run: terraform apply $PLANFILE - -# Validation schemas (for validating atmos stacks and components) -schemas: - # https://json-schema.org - jsonschema: - # Can also be set using 'ATMOS_SCHEMAS_JSONSCHEMA_BASE_PATH' ENV var, or '--schemas-jsonschema-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/jsonschema" - # https://www.openpolicyagent.org - opa: - # Can also be set using 'ATMOS_SCHEMAS_OPA_BASE_PATH' ENV var, or '--schemas-opa-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/opa" - # https://cuelang.org - cue: - # Can also be set using 'ATMOS_SCHEMAS_CUE_BASE_PATH' ENV var, or '--schemas-cue-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/cue"