Anyone happen to know of anyway to sync ssm parame...
# help
g
Anyone happen to know of anyway to sync ssm parameters from a root aws account to every account in the org?
s
what I’ve done is made it so other AWS accounts can read SSM params in the root account. they’re not sync’d or copied. does that work for you?
g
That wouldn't work I want to be able to use the cdk ssm to load parameters and it doesn't support cross account fetching
s
ahh gotcha. yeah, I’m just fetching the SSM parameters in my code
f
Would it work if you fetched SSM across account using aws sdk at build time. Does that work for you?
g
Yeah that might be the best, not sure how to fetch ssm cross account so if either one of you could enlighten me on how to do that 😅
s
sure! so here’s the function I wrote to fetch SSM params from either the AWS account the stack is running on, or from the primary/parent AWS account:
that
SSM_ROLE_ARN
should be the ARN of the primary account’s IAM role that grants access to sub-accounts. it looks like this:
Copy code
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": "ssm:GetParameter",
      "Resource": "*"
    }
  ]
}
and for that IAM role’s trust relationship, you want this:
Copy code
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<sub account ID>:root"
      },
      "Action": "sts:AssumeRole",
      "Condition": {}
    }
  ]
}