future-france-34957
06/24/2022, 10:03 PMPOLICY = f"""{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:GetParameters"
],
"Resource": [
"arn:aws:ssm:{aws_region}:{aws_account}:parameter/{env_stack}.api.config-location-s3"
],
"Effect": "Allow"
}
]
}"""
# Custom API-Tasks ECS Role Policy
self.api_tasks_ecs_permissions = iam.RolePolicy(
resource_name="api-tasks-ecs-permissions",
role=self.api_tasks_ecs_role.id,
policy=json.dumps(POLICY)
)
This fails with SyntaxError: f-string: expressions nested too deeply
Anyone know how I can achieve this?billowy-army-68599
future-france-34957
06/24/2022, 10:06 PMjson.dumps(POLICY)
billowy-army-68599
future-france-34957
06/24/2022, 10:08 PM# Custom API-Tasks ECS Role Policy
self.api_tasks_ecs_permissions = iam.RolePolicy(
resource_name="api-tasks-ecs-permissions",
role=self.api_tasks_ecs_role.id,
policy=json.dumps({
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:GetParameters"
],
"Resource": [
f"arn:aws:ssm:{aws_region}:{aws_account}:parameter/{env_stack}.api.config-location-s3"
],
"Effect": "Allow"
}
]
})
)
It errors with:
Error putting IAM role policy api-tasks-ecs-permissions-e425b0b: MalformedPolicyDocument: The policy failed legacy parsing
POLICY = {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:GetParameters"
],
"Resource": [
"arn:aws:ssm:" + aws_region + ":" + aws_account +
":parameter/" + env_stack + ".api.config-location-s3"
],
"Effect": "Allow"
}
]
}
# Custom API-Tasks ECS Role Policy
self.api_tasks_ecs_permissions = iam.RolePolicy(
resource_name="api-tasks-ecs-permissions",
role=self.api_tasks_ecs_role.id,
policy=json.dumps(POLICY)
)
Gets
TypeError: can only concatenate str (not "AwaitableGetRegionResult") to str
aws_region = aws.get_region()
, it doesn’t return string, my bad
Forgot the .name