This question might not even make sense, but is th...
# atmos
m
This question might not even make sense, but is there a best practice for configuring Atmos stores to use each reference architecture account's SSM Parameter Store rather than a centralized store? For example, if I have a
dev-use1-log
,
dev-usw2-log
,
stage-use1-iam
, and others along that pattern, can I do something like this in my `atmos.yaml`:
Copy code
# Atmos Stores
# https://atmos.tools/core-concepts/projects/configuration/stores/
stores:
  use1/ssm:
    type: aws-ssm-parameter-store
    options:
      region: us-east-1
  usw2/ssm:
    type: aws-ssm-parameter-store
    options:
      region: us-west-2
and then reference the per-account store via:
Copy code
- name: "AWS-AWSManagedRulesBotControlRuleSet"
            priority: 100
            statement:
              # https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-bot.html
              name: AWSManagedRulesBotControlRuleSet
              vendor_name: AWS
              scope_down_not_statement_enabled: true
              scope_down_statement:
                byte_match_statement:
                  field_to_match:
                    single_header:
                      name: "secret-token"
                  positional_constraint: "EXACTLY"
                  search_string: !store use1/ssm waf/defaults /waf/defaults/secret_token
                  text_transformation:
                    - priority: 101
                      type: "NONE"
My goal is to be able to directly pull from each account's store into my stacks (if that makes sense)
g
@Andriy Knysh (Cloud Posse)
a
@Michael if it works, it would be a good practice to separate SSM stores per account (and per Org in your case)
let us know if see any issues with that (we will fix it fast)
👍 1
m
Awesome, will give it a go. Thanks!
a
you'll need to specify diff roles per store
Copy code
read_role_arn: "arn:aws:iam::123456789012:role/ssm-read-role"  # Optional role ARN for read operations
      write_role_arn: "arn:aws:iam::123456789012:role/ssm-write-role"  # Optional role ARN for write operations
from your accounts
they can be the terraform roles (which already have permissions to read/write to SSM)
and then reference the per-account store via:
you will also need to configure hooks to write to the store in a particular format (since
!store
expects that format)
hooks will be different per your accounts since they ref a particular store
m
Ultimately, my goal is to use the
!store
functionality to directly access SSM parameters across accounts without needing to do any Terraform output/remote state work. Right now, I'm using parameter stores across 15+ accounts, so configuring stores for each of them feels repetitive so I was curious if there was a way to just specify east and west and then dynamically assume the role for each stack if that makes sense
a
yes, it makes perfect sense
the idea is,
!store
expects a particular data format (written by
hook
)
but we want to be able to read any data in any format from any path (written by terraform, or manually, or by any other means)
which
!store.key
would do
❤️ 1
@PePe Amengual let's finish it, let me know if you need help to go through the comments and tests (we can finish it together)
❤️ 1
➕ 2
p
I have time today
I pushed the changes and I tested locally and it works
🔥 1
let me know about feedback and tests
a
thanks @PePe Amengual i can add tests to your branch (if you need help on that), the bots will not allow it to pass w/o having all the tests in place
e
a
yes,
!store.get
, PePe has it correctly in the PR
p
I believe I added tests, or I'm missing some?
a
i'll check eveything and let you know, thank you PePe
p
Thanks,
a
@PePe Amengual thank you again for the PR. I updated the code and tests, and improved the docs. Merged to
main
It will be available in the next release (ETA by Monday) CC @Michael
fast parrot 4
🙏 1
p
nice, would that fix the describe affected regression?
a
i tested it and didn’t see any issues. The stack flag is always taken into account regardless of the other flags used. We need to review it in your setup, might be something else
p
our setup is, terraform outputs plus depends_on. Then describe affected is run with --stack option it tries to run terraform.output functions of other stacks
not just the ones from the stack passed into the flag
a
@PePe Amengual can you please remind me all the issues that you encountered (one of them is the
--stack
flag together with the
--include-dependents
flag, which we tested and it work correctly, at least in our tests)
(btw, your
!store.get
YAML function is also in the last Atmos release, thanks)
p
The problem with describe-affected and the
--stack
flag is that it processes!terraform.output functions of other stacks and not just the stack that was selected
without !terraform.output functions it seems to work fine
and the other one is not a bug, is more of an enhancement https://sweetops.slack.com/archives/C031919U8A0/p1753981657197049
a
The problem with describe-affected and the
--stack
flag is that it processes!terraform.output functions of other stacks and not just the stack that was selected
ok, i see, thanks (this needs to be addressed)
regarding
metadata.locked: true
it was meant to be used to disable component updates (terraform apply), but still enable reads (TF plans). It was not meant to serve as an enable flag for
describe affected
describe affected` is a read operation
i'm not sure if we should "mix" these two diff things
we prob can do one of the following: • Add a flag to
atmos.yaml
to enable using
metadata.locked
in
describe affected
(so by default, it does not, but you can enable it) • Add a separate attribute to
metadata
related to describe affected
p
that could work
Our goal is to have shared infra in monorepo but service repos "can't see" infra that do not belong to them, like a vpc or something like that.
👍 1
a
@PePe Amengual i tested it,
describe affected
does not process Atmos YAML functions (and Go templates) by default. When you execute
atmos describe affected --pager off --stack ue1-prod
- no YAML functions aand Go templates are processed in all stacks (not only in
ue1-prod
. You can use
--process-functions
and
--process-templates
flags to explicitly process YAML funcs and templates
atmos describe affected --pager off --process-functions --stack ue1-prod
p
are you saying I should turn off processing y'all functions?
I have it explicitly enabled
a
to summarize, `atmos describe affected --pager off --stack ue1-prod`: • will not process YAML functions and templates at all (for all stacks) • will find affected components only in
ue1-prod
`atmos describe affected --pager off --process-functions --stack ue1-prod`: • will process YAML functions (including
!terraform.output)
just in the
ue1-prod
stack (not in all stacks) • will find affected in
ue1-prod
stack only
p
ok, in your second example is where I see functions of other stacks being processed, I could post more details tomorrow
a
hmm, i don't see functions in the other stacks processed (b/c it does not process the other stacks at all, skips them)
e
(the pager is automatically disabled on headless terminals, such such as in GitHub or when piping. The paging behavior can be controlled in the Atmos config. Just chiming in since I see it in the commands there, and it’s not necessary)