Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add imports to stack output. Add stacks to each component output #24

Merged
merged 14 commits into from
Apr 13, 2021

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented Apr 12, 2021

what

  • Add imports to stack output
  • Add stacks to each component output

why

  • imports attribute shows all imported stacks for the current stack - can be used in CI/CD pipelines to determine stack dependencies
  • stacks attribute shows all the stacks the component (and its base component, if present) is declared in - can be used in CI/CD pipelines (e.g. Spacelift) to determine all stacks that the component depends on,
    and to provision triggers for all the dependencies (once any of the stack config files changes, the component's job will be triggered)

test

imports:
  - eks/eks-defaults
  - globals
  - uw2-globals
terraform:
  aurora-postgres:
    backend:
      acl: bucket-owner-full-control
      bucket: eg-uw2-root-tfstate
      dynamodb_table: eg-uw2-root-tfstate-lock
      encrypt: true
      key: terraform.tfstate
      region: us-west-2
      role_arn: arn:aws:iam::XXXXXXXXXXXX:role/eg-gbl-root-terraform
      workspace_key_prefix: aurora-postgres
    backend_type: s3
    stacks:
    - globals
    - uw2-dev
    - uw2-globals
    - uw2-prod
    - uw2-staging
    - uw2-uat
    env:
      ENV_TEST_1: test1
      ENV_TEST_2: test2
      ENV_TEST_3: test3
      ENV_TEST_4: test4
      ENV_TEST_5: test5
      ENV_TEST_6: test6
      ENV_TEST_7: test7
    settings:
      spacelift:
        autodeploy: false
        workspace_enabled: false
      version: 0
    vars:
      cluster_size: 1
      environment: uw2
      instance_type: db.r4.large
      namespace: eg
      region: us-west-2
      stage: dev
  aurora-postgres-2:
    backend:
      acl: bucket-owner-full-control
      bucket: eg-uw2-root-tfstate
      dynamodb_table: eg-uw2-root-tfstate-lock
      encrypt: true
      key: terraform.tfstate
      region: us-west-2
      role_arn: arn:aws:iam::XXXXXXXXXXXX:role/eg-gbl-root-terraform
      workspace_key_prefix: aurora-postgres
    backend_type: s3
    component: aurora-postgres
    stacks:
    - globals
    - uw2-dev
    - uw2-globals
    - uw2-prod
    - uw2-staging
    - uw2-uat
    env:
      ENV_TEST_1: test1_override2
      ENV_TEST_2: test2_override2
      ENV_TEST_3: test3
      ENV_TEST_4: test4
      ENV_TEST_5: test5
      ENV_TEST_6: test6
      ENV_TEST_7: test7
      ENV_TEST_8: test8
    settings:
      spacelift:
        autodeploy: true
        branch: dev
        triggers: []
        workspace_enabled: true
      version: 0
    vars:
      cluster_size: 1
      environment: uw2
      instance_type: db.r4.xlarge
      namespace: eg
      region: us-west-2
      stage: dev

helmfile:
  alb-controller:
    stacks:
    - eks/eks-defaults
    - uw2-dev
    - uw2-prod
    - uw2-staging
    - uw2-uat
    env: {}
    settings: {}
    vars:
      account_number: "1234567890"
      chart_values:
        enableCertManager: true
      environment: uw2
      installed: true
      namespace: eg
      region: us-west-2
      ssm_region: us-west-2
      stage: dev

@aknysh aknysh requested review from osterman, mcalhoun and Nuru April 12, 2021 20:20
@aknysh aknysh self-assigned this Apr 12, 2021
Copy link
Member

@mcalhoun mcalhoun left a comment

Choose a reason for hiding this comment

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

LGTM! I just made one minor comment that you might want to consider.

@@ -39,29 +53,38 @@ func ProcessYAMLConfigFiles(filePaths []string) ([]string, error) {
// ProcessYAMLConfigFile takes a path to a YAML config file,
// recursively processes and deep-merges all imports,
// and returns stack config as map[interface{}]interface{}
func ProcessYAMLConfigFile(filePath string) (map[interface{}]interface{}, error) {
func ProcessYAMLConfigFile(filePath string, importsList *[]string) (map[interface{}]interface{}, *[]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you really want a pointer here? I would consider passing by value unless there is a strong reason. It makes unexpected side-effects less likely.

Copy link
Member Author

@aknysh aknysh Apr 12, 2021

Choose a reason for hiding this comment

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

it's uses recursion, and by-value did not work (it was losing data b/w the recursion steps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants