Unable to extract SSM parameters, AccessDeniedException

0

I'm attempting to get my Fargate Task to access an SSM store. The error I'm getting from cloud logs is:

Unable to Extract SSM parameters! AccessDeniedException: User: arn:aws:sts::9xxxxxxxxxxx:assumed-role/my-latest-fargate-role/b9b873c1d5e44520a58e26993e3bad63 is not authorized to perform: ssm:GetParameter on resource: arn:aws:ssm:us-west-2:9xxxxxxxxxx:parameter/my_url because no identity-based policy allows the ssm:GetParameter action

The resulting AIM role looks like this:

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Action": [
				"kms:Decrypt"
			],
			"Resource": "arn:aws:kms:us-west-2::key/*",
			"Effect": "Allow"
		},
		{
			"Action": [
				"ssm:GetParameter",
				"ssm:GetParameters",
				"ssm:DescribeParameters"
			],
			"Resource": "arn:aws:ssm:us-west-2::parameter/*",
			"Effect": "Allow"
		}
	]
}

I'm not certain why this isn't working. If it matters, the parameter itself is a plain text string, because I'm testing that before I try to extract encrypted ones.

I've confirmed that this role is attached to the right task. The entire deployment is going as expected. This is the only error I'm getting.

Typescript code is this in case that matters:

try {
    console.log("Attempting to extract parameters from AWS SSM");
    const ssmClient = new SSMClient({ region: 'us-west-2' });
    const command = {
        Name: 'name_of_parameter',
        WithDecryption: true
    };
    const request = new GetParameterCommand(command);
    const my_url = await ssmClient.send(request);
    console.log("extracted secret parameter", mongo_url);
    //@ts-ignore
    config.my_url = mongo_url.Parameter.Value || "could not extract value";
}
catch (e) {
    console.log("Unable to Extract SSM parameters!", e);
}
1 個回答
1

Hello.

Is it possible that the parameter store ARN is written incorrectly?
Looking at the document, it looks like this:
https://docs.aws.amazon.com/ja_jp/service-authorization/latest/reference/list_awssystemsmanager.html#awssystemsmanager-parameter

arn:${Partition}:ssm:${Region}:${Account}:parameter/${ParameterNameWithoutLeadingSlash}

In other words, don't you need to include the AWS Account ID as shown below?

arn:aws:ssm:us-west-2:AWS Account ID:parameter/*
profile picture
專家
已回答 1 個月前
profile pictureAWS
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南