looks like I found another bug `atmos describe aff...
# atmos
p
looks like I found another bug
atmos describe affected --include-settings=false --include-dependents=true --stack=dev-wus3 --logs-level=Debug
will include process all stacks. include-dependents is not respecting the --stack option
✅ 1
a
we'll have to test it @Gabriela Campana (Cloud Posse) please create a task
✅ 1
p
this is broken since 174 I believe
a
yea, looks like it, thanks for testing and reporting @PePe Amengual
e
Any update here? This is impeding my ability to use pro 😕
Also, happy to contribute 🙂
a
we are working on it, should be released in a day or two
🙌 1
e
Out of interest: is it possible to run describe affected with the upload flag while not executing any e.g. terraform init commands? For my use-case, each stack maps to a different cloud account which means different credentials. I can fix this with GitHub environments and multiple runs of the describe affected action, but it would be much nicer if I could just run describe affected once
a
describe affected
does not execute
terraform init
(nor other terraform commands) - it works with the stack manifests (from two diff commits or branches) and compares the stack configs from both
@Ed please provide more info why you think
terraform init
is executed
i guess maybe it's related to the YAML functions like `!`terraform.state`` or
!terraform.output
the functions are executed, and they need to be executed to be able to compare the final values (and not the strings containing the functions themselves, which will always be the same and not affected)
so yes,
!terraform.output
will execute
terraform init
but
!terraform.state
will not since it reads directly from the state storage (s3 bucket for AWS)
but it will still need credentials to access the bucket, and it currently only supports AWS (I think you are using Azure)
----
for
describe affected
, you can use these flags
Copy code
--process-templates
Enable/disable processing of all Go templates in Atmos stacks manifests when executing the command. If the flag is not provided, it's set to true by default.

atmos describe affected --process-templates=false

--process-functions
Enable/disable processing of all Atmos YAML functions in Atmos stacks manifests when executing the command. If the flag is not provided, it's set to true by default.

atmos describe affected --process-functions=false
to disable processing the YAML functions
but in this case, Atmos will not be able to compare the final values (returned from the functions) and will just compare the strings containing the functions - which is prob not what you'd expect from
describe affected
e
Hi @Andriy Knysh (Cloud Posse), that's really helpful My codebase contains no use of YAML functions as you mention, but the following command:
Copy code
$ atmos describe affected --logs-level=Debug --repo-path base-ref/  --include-settings=true --include-dependents=true --process-functions=false --process-templates=false
Leads to the following logs:
Copy code
DEBU Set logs-level=debug logs-file=/dev/stderr
DEBU Atmos JSON Schema is not configured. Using the default embedded schema
DEBU Validating all YAML files in the folder and all subfolders (excluding template files) folder=stacks
DEBU Current HEAD="aa58502e43011913d5fa7439b041b8493bcca4d2 refs/heads/main"
DEBU Current BASE="27356168dbf0622eca8ba9290215351f37e0a5b7 HEAD"
...
DEBU Finding difference between the current working branch and remote target branch
DEBU Found difference between the current working branch and remote target branch
DEBU Changed
  files=
  │  .github/workflows/affected-stacks.yml              | 3 +--
DEBU ProcessTmplWithDatasources template=describe-stacks-all-sections
DEBU ProcessTmplWithDatasources template=describe-stacks-all-sections evaluation=1
DEBU Executing template function function="atmos.Component(blob, test-default-dev)"
DEBU Found component 'blob' in the stack 'test-default-dev' in the stack manifest 'orgs/test/test-default-dev'
DEBU ProcessTmplWithDatasources template=templates-all-atmos-sections
DEBU ProcessTmplWithDatasources template=templates-all-atmos-sections evaluation=1
DEBU ProcessTmplWithDatasources: processed template=templates-all-atmos-sections
DEBU Writing backend config file=components/terraform/blob/backend.tf.json
DEBU Wrote backend config file=components/terraform/blob/backend.tf.json
DEBU Writing provider overrides file=components/terraform/blob/providers_override.tf.json
DEBU Wrote provider overrides file=components/terraform/blob/providers_override.tf.json
DEBU Terraform environment file not found. No action needed. file=components/terraform/blob/.terraform/environment
DEBU Executing terraform command="terraform init blob -s test-default-dev" component=blob stack=test-default-dev
As is apparent in the logs, my stackfile does contain
atmos.Component(...)
so is that the cause of the issue? Is there a flag which would prevent this from evaluating? All I want to do is generate a stack dependency JSON (i.e. just looking at the stacks and their
depends_on
settings)
a
atmos.Component(...)
executes
terraform init
and other terraform commands
--process-templates=false
was suppossed to disable executing templates and template functions, which it apparently does not do anymore - prob related to the similar issue that @PePe Amengual pointed out
we'll have to review this
we already working on
include-dependents is not respecting the --stack option
, will review
--process-templates=false
as well
@Ed thank you for testing and pointing at the issues
e
Let me know if I can help with anything 🙂
Morning @Andriy Knysh (Cloud Posse) - does the latest atmos release address this issue? I know you're already working on a solution not it's not clear to me if the release notes are talking about the same issue in this thread
a
@Ed are you from the same team as @PePe Amengual? and seeign the same issues?
i don't see the issues you are describing, please provide more info or maybe share your config
e
@Andriy Knysh (Cloud Posse) I'm not from the same team as @PePe Amengual, but I do see the describe affected regression that he references. For context, I'm experimenting with atmos pro and want to use the
--upload
flag. From the atmos codebase I can see this is equivalent to:
Copy code
atmos describe affected ... --include-dependents=true --include-settings=true
In total, the command I'm running is:
Copy code
atmos describe affected --pager=off --verbose=true --repo-path base-ref/ --include-dependents=true --include-settings=true --process-functions=false
In spite of the process-functions flag I see that, as in the logs I shared above, the
atmos.Component(...)
is executed:
Copy code
DEBU Executing template function function="atmos.Component(web_application_firewall_policy, test-default-dev)"
The same happens if I pass
--stack=test-default-dev
and this is breaking for my use case. I don't know if this really helps, but here is my `atmos.yaml`:
Copy code
base_path: "./"

components:
  terraform:
    command: "terraform"
    base_path: "components/terraform"
    apply_auto_approve: false
    deploy_run_init: true
    init_run_reconfigure: true
    auto_generate_backend_file: true

stacks:
  base_path: "stacks"
  included_paths:
    - "orgs/**/*"
  excluded_paths:
    - "**/_defaults.yaml"
  name_pattern: "{tenant}-{namespace}-{stage}"

logs:
  file: "/dev/stderr"
  level: Info

workflows:
  base_path: "workflows/"

templates:
  settings:
    enabled: true

integrations:
  github:
    gitops:
      terraform-version: 1.9.8
      infracost-enabled: false
      matrix:
        sort-by: .stack_slug
        group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
I'm on atmos v1.186.0 on linux/amd64
a
@Ed thanks for sharing. I'm not seeing that when executing locally, but let me test again, I'll let you know
e
I'm stepping through the describe affected command locally so will update when I figure out what's happening 🙂
Here we go @Andriy Knysh (Cloud Posse): The
describe affected
command executes this method:
Copy code
// Execute executes `describe affected` command.
func (d *describeAffectedExec) Execute(a *DescribeAffectedCmdArgs) error {
	var affected []schema.Affected
	var headHead, baseHead *plumbing.Reference
	var repoUrl string
	var err error
    ...
Which has a switch for repo/clone etc. These function calls respect the
DescribeAffectedCmdArgs
After that we hit the
addDependentsToAffected
method:
Copy code
// Add dependent components and stacks for each affected component
	if len(affected) > 0 && a.IncludeDependents {
		err = d.addDependentsToAffected(a.CLIConfig, &affected, a.IncludeSettings)
		if err != nil {
			return err
		}
	}
Which does not pass the e.g.
ProcessYamlFunctions
Ultimately this calls
ExecuteDescribeStacks
which has the process yaml functions arg hardcoded to true (see code):
Copy code
stacks, err := ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, true, true, false, nil)
	if err != nil {
		return nil, err
	}
Below is the function signature:
Copy code
func ExecuteDescribeStacks(
	atmosConfig *schema.AtmosConfiguration,
	filterByStack string,
	components []string,
	componentTypes []string,
	sections []string,
	ignoreMissingFiles bool,
	processTemplates bool,
	processYamlFunctions bool,
	includeEmptyStacks bool,
	skip []string,
) (map[string]any, error)
p
some details :
Copy code
Download action repository 'cloudposse/github-action-atmos-affected-stacks@e6a7d6ed50b769266e2356dc96d5bd1db8bd5350' (SHA:e6a7d6ed50b769266e2356dc96d5bd1db8bd5350)
Setup atmos version spec 1.186.0
Attempting to download 1.186.0...

Run base_cmd="atmos describe affected --include-settings=false --file affected-stacks.json --repo-path \"$GITHUB_WORKSPACE/base-ref\""
  base_cmd="atmos describe affected --include-settings=false --file affected-stacks.json --repo-path \"$GITHUB_WORKSPACE/base-ref\""
  
  if [[ "false" == "true" ]]; then
    base_cmd+=" --include-spacelift-admin-stacks=true"
  elif [[ "true" == "true" ]]; then
    base_cmd+=" --include-dependents=true"
  fi
  
  if [[ -n "dev-wus3" ]]; then
    base_cmd+=" --stack=dev-wus3"
  fi
  
  if [[ "false" == "true" ]]; then
    base_cmd+=" --skip=terraform.output"
  fi
  
  if [[ "true" == "false" ]]; then
    base_cmd+=" --process-templates=false"
  fi
  
  if [[ "true" == "false" ]]; then
    base_cmd+=" --process-functions=false"
  fi
  eval "$base_cmd"
  affected=$(jq -c '.' affected-stacks.json)
  printf "%s" "affected=$affected" >> $GITHUB_OUTPUT
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ATMOS_CLI_CONFIG_PATH: /runner/_work/pepe-iac/pepe-iac/config
    ATMOS_BASE_PATH: ./
    ATMOS_VERSION: 1.186.0
    ARM_USE_OIDC: true
    ENVIRONMENT: DEV
    ARM_CLIENT_ID: ***
    ARM_SUBSCRIPTION_ID: ***
    ARM_TENANT_ID: ***
  
✗ Fetching api_management_identity output from apimanagement/be in prod-wus3
# Error                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
failed to execute terraform output for the component apimanagement/be in the stack prod-wus3. Error: exit status 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Error: retrieving Storage Account (Subscription: "***" Resource Group Name: "prod-wus3-tfstate-rg" Storage Account Name: "prodwus3tfstatestvaom"): unexpected status 404 (404 Not Found) with error: ResourceGroupNotFound: Resource group 'prod-wus3-tfstate-rg' could not be found.
a
@Ed @PePe Amengual thanks. It happens only when passing
--include-dependents
- we'll fix it
@Ed thanks a lot for testing
p
ahhh cool, I'm glad you were able to reproduce
e
Same issue here @Andriy Knysh (Cloud Posse):
Copy code
providedComponentSection, err := ExecuteDescribeComponent(component, stack, true, true, nil)
I've amended
ExecuteDescribeDependents
to accept two more args:
Copy code
processTemplates bool,
	processYamlFunctions bool,
Which I pass to
ExecuteDescribeStacks
and
ExecuteDescribeComponent
. Running this locally gives me exactly what I need. Do you want me to fix the tests and submit a PR or will you guys handle it internally? 🙂
a
desxcribe dependents
needs the same flags as
describe affected
(including updating the docs) - we'll handle that
@PePe Amengual @Ed we already fixed the issues with processing YAML funcs and templates when
--include-dependents
is specified for
atmos describe affected
. Also added a flag
--exclude-locked
to
atmos describe affected
to explicitly exclude the locked components (
metadata.locked: true
). Will be released in a day or two
❤️ 1
p
NIce!
e
That's brilliant @Andriy Knysh (Cloud Posse) - thank you! And good to know about
metadata.locked
. I was looking for something exactly like that today 🙂
👍 2
a
@PePe Amengual @Ed please try this release https://github.com/cloudposse/atmos/releases/tag/v1.188.0
👀 1
p
Copy code
Acquiring v1.188.0 from https://github.com/cloudposse/atmos/releases/download/v1.188.0/atmos_1.188.0_linux_amd64
Renaming downloaded file...
Successfully renamed atmos from /runner/_work/_temp/76576576575 to /runner/_work/_actions/cloudposse/github-action-setup-atmos/atmos/atmos
Successfully installed atmos to /runner/_work/_actions/cloudposse/github-action-setup-atmos/atmos
Cached version v1.188.0 for x64 in /opt/hostedtoolcache/atmos/1.188.0/x64
Run base_cmd="atmos describe affected --include-settings=false --file affected-stacks.json --repo-path \"$GITHUB_WORKSPACE/base-ref\""
  base_cmd="atmos describe affected --include-settings=false --file affected-stacks.json --repo-path \"$GITHUB_WORKSPACE/base-ref\""
  
  if [[ "false" == "true" ]]; then
    base_cmd+=" --include-spacelift-admin-stacks=true"
  elif [[ "true" == "true" ]]; then
    base_cmd+=" --include-dependents=true"
  fi
  
  if [[ -n "dev-wus3" ]]; then
    base_cmd+=" --stack=dev-wus3"
  fi
  
  if [[ "false" == "true" ]]; then
    base_cmd+=" --skip=terraform.output"
  fi
  
  if [[ "true" == "false" ]]; then
    base_cmd+=" --process-templates=false"
  fi
  
  if [[ "true" == "false" ]]; then
    base_cmd+=" --process-functions=false"
  fi
  eval "$base_cmd"
  affected=$(jq -c '.' affected-stacks.json)
  printf "%s" "affected=$affected" >> $GITHUB_OUTPUT
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ATMOS_CLI_CONFIG_PATH: /runner/_work/pepe-iac/pepe-iac/config
    ATMOS_BASE_PATH: ./
    ATMOS_VERSION: 1.188.0
    ARM_USE_OIDC: true
    ENVIRONMENT: DEV
✓ Fetching storage_account_primary_web_hostname output from web-app-storage in dev-wus3
✓ Fetching .frontdoor_custom_domain_validation_tokens["dev.pepe.cloud"] output from frontdoor in dev-wus3
✓ Fetching api_management_identity output from apimanagement/be in dev-wus3
✗ Fetching api_management_identity output from apimanagement/be in sbox-wus3
# Error                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
failed to execute terraform output for the component apimanagement/be in the stack sbox-wus3. Error: exit status 1


Error: retrieving Storage Account (Subscription: "***" Resource Group Name: "sbox-wus3-tfstate-rg" Storage Account Name: "sboxwus3stateetc"): unexpected status 404 (404 Not Found) with error: ResourceGroupNotFound: Resource group 'sbox-wus3-tfstate-rg' could not be found.
a
what’s the error related to?
p
Is executing terraform.outputs functions in the wrong stack
a
what does it mean, the wrong stack? if you execute the command in the terminal (not gh actions), what do you see? (note it’s difficult to understand what’s going on in your stacks without being in the context)
p
the dev-wus3 stacks has no terraform.output functions from other stacks
it only references dev-wus3 component outputs
we call the components the same in all stacks
apimanagement/be
the output in question :
Copy code
system_managed_identity: !terraform.output apimanagement/be api_management_identity
a
are the dependents from sbox?
p
no
a
if you run it with—include-dependents=false, what happens?
p
let me try
Untitled
it works right away
a
so the function that reads from sbox is in one of the dependents
p
no
remember we run describe-affected with --stack, so we are just looking for dependants on that stack
we do not use references from other stacks in terraform.output functions
if that was the case then we should see
Copy code
Fetching api_management_identity output from apimanagement/be in sbox-wus3.....
in the output I shared
I think when you enable dependants for some reason is is compiling all terraform.output functions regardless of the stack
a
I understand what you want to achieve. This is an interesting case. I'll explain it tomorrow morning, and what needs to be done here (we need another flag)
@PePe Amengual here is some boring theory, and then a solution (tl;dr; we need to update Atmos, add another flag, to support your use-case)
when you execute
atmos describe affected --include-dependents
, Atmos will process all components in ALL stacks to find the affected and then all component in all stacks to find the dependents of all affected components
when you execute
atmos describe affected --include-dependents --stack <stack>
, Atmos will process all components in the provided stack to find the affected and then all component in ALL stacks to find the dependents of all affected components
since in the later case Atmos will execute
describe dependents
, let's consider it (since it's easier to understand):
atmos describe dependents component --stack stack
- will find the dependents (from all stacks) of the provided component in the provided stack
we can make it to look for the dependents in the same stack only (provided on the command line as
--stack
), and it would work for your case, but the general case will be broken. Here's why: if we make
atmos describe dependents component --stack stack
to search for dependents in the provided stack
stack
only, we'll never be able to specify to search for dependents in all stack. So here we have two different 'stacks': • The stack provided on the command line (to specify that the provided component is from that stack) • And some new stack to filter the dependents by
In other words, to support both cases (and not break any existing functionality), we need to add a flag
--dependents-stack
atmos describe dependents component --stack stack
- will find the dependents from ALL stacks for the specified component in the specified stack
atmos describe dependents component --stack stack --dependents-stack stack
- will find the dependents in the stack
stack
onlt for the the specified component in the specified stack
same thing will be applied to
describe affected
atmos describe affected component --stack stack --include-dependents
- will find the affected components from the specified stack and the dependents of the affected components from all stacks
atmos describe affected component --stack stack --include-dependents --dependents-stack stack
- will find the affected components from the specified stack and the dependents of the affected components from the specified stack (this is your case)
only this way we'll be able to support both cases
@Gabriela Campana (Cloud Posse) please create atask for Atmos: Add
--dependents-stack
flag to
atmos describe affected
and
atmos describe dependents
commands to filter the dependents by the provided stack
✅ 1
p
I totally understand. Basically, we will break any dependencies between stacks if you do not add the new flag, it make sense
e
Hi @Andriy Knysh (Cloud Posse), I'm not sure if this is a bug or if my setup is overlooking something, but I've found that the
metadata.enabled: false
field isn't always respected by the
atmos describe affected command
To be more specific, I have something like this:
Copy code
# stacks/catalog/federated_identity_credentials/defaults.yaml
components:
  terraform:
    federated_identity_credential:
      settings:
        depends_on:
          "0":
            component: "resource_group"
          "1":
            component: "user_assigned_identity"
          "2":
            component: "cross_tenant_application"
      metadata:
        component: federated_identity_credential
      vars:
        resource_group_name: "rg-{{ .vars.tenant }}-{{ .vars.namespace }}-{{ .vars.stage }}"
        application_federated_identity_credentials:
          container_app_identity:
            application_name: "<blah>"
            audiences: ["api://AzureADTokenExchange"]
            display_name: "fic-container-app"
            user_assigned_identity_name: "<blah>"

# stacks/orgs/example/example-default-dev.yaml
import:
  - catalog/federated_identity_credentials/defaults

vars:
  tenant: "example"
  namespace: "default"
  stage: "dev"

components:
  terraform:
    federated_identity_credentials:
      metadata:
        enabled: false
        component: federated_identity_credentials
When I run
atmos describe affected
I pass
--exclude-locked
but I still see that
federated_identity_credentials
ends up being caught in the output JSON. I may have missed something here, but is that the expected behaviour?
a
@Ed i'll check it and let you know
❤️ 1
p
e
I’m still seeing this - kinda annoying to have failed plan/apply jobs all the time since the metadata label doesn’t seem to be respected. If I have some time later, I’ll build it locally and try to isolate the problem
a
@Ed
metadata.enabled: false
is respected in the affected components, but it was not respected in the dependents (when using the flag
--include-dependents
This is already fixed and will be available in the next release (today/tomorrow). Unless you are having a diff issue, this should fix it for you
👀 1
@PePe Amengual also in the next release, we'll have the flag
--dependents-stack
to filter the dependent components by he stack
atmos describe affected --stack stack --include-dependents --dependents-stack stack
you will use it like the above ^
--stack
- is to filter the affected by the stack
--dependents-stack
- is to filter th dependents by the same stack
(this way, Atmos will not execute the YAML functions on the other stacks for both affected and dependents)
e
Thanks @Andriy Knysh (Cloud Posse) - will check out the next release and see if that fixes things 🙂
p
any news on this?
👀 1
g
@Andriy Knysh (Cloud Posse)
a
@PePe Amengual this will be improved in the next Atmos release (ETA in the next few days)
p
ok
this is kinda blocking us actually
a
this is fixed in https://github.com/cloudposse/atmos/pull/1590 (will be available in the next release next week)
❤️ 1
@PePe Amengual @Ed The fix is in this release https://github.com/cloudposse/atmos/releases/tag/v1.194.0 Please try and let us know if you see any issues
fast parrot 2
please use the latest release https://github.com/cloudposse/atmos/releases/tag/v1.194.1 (has some fixes) @PePe Amengual @Ed did you test the new features in
atmos describe affected
?
p
I did a quick test but now is failing somewhere else and I have not had time to look into this, maybe today
👍 1
a
please use 1.194.1
p
ahhhh ok, I have not tried that , I will report back
e
Have not been able to yet @Andriy Knysh (Cloud Posse) but will report back when I have 🙂
👍 1