Describe the bug
Was attempting to create an IAM policy to grant console access to developers who can trigger builds via GitHub commits, found that the resource ARN patterns for Amplify resources are inconsistently applied.
To Reproduce
Using the IAM policy generator, create a policy which grants all Amplify actions on any amplify resource. Produces the following:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"amplify:CreateApp",
"amplify:ListApps"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": "arn:aws:amplify:*:*:apps/*/branches/*"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": [
"arn:aws:amplify:*:*:apps/*/domains/*",
"arn:aws:amplify:*:*:apps/*/branches/*/jobs/*"
]
},
{
"Sid": "VisualEditor3",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": "arn:aws:amplify:*:*:apps/*"
}
]
}
Create an account role, attach the previously created policy.
Open the browser's JS console and look for 403s, which will look like:
...does not have amplify:ListDomainAssociations on resource: arn:aws:amplify:<REGION>:<ACCOUNT_ID>:/apps/<APP_HASH>/domains
...does not have amplify:ListWebhooks on resource: arn:aws:amplify:<REGION>:<ACCOUNT_ID>:/apps/<APP_HASH>/webhooks
Note the ARN pattern difference (slash prepended to apps):
arn:aws:amplify:*:*:apps/...arn:aws:amplify:<REGION>:<ACCOUNT_ID>:/apps/...apps in all resource ARN patternsIn the JS console, find 403 messages like:
...does not have amplify:ListBranches on resource: arn:aws:amplify:<REGION>:<ACCOUNT_ID>:apps/<APP_HASH>/branches/*
...does not have arn:aws:amplify:<REGION>:<ACCOUNT_ID>:apps/<APP_HASH>/branches/*
Return to primary role, alter IAM policy to be as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"amplify:CreateApp",
"amplify:ListApps"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": [
"arn:aws:amplify:*:*:/apps/*/branches/*",
"arn:aws:amplify:*:*:apps/*/branches/*"
]
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": [
"arn:aws:amplify:*:*:/apps/*",
"arn:aws:amplify:*:*:apps/*"
]
},
{
"Sid": "VisualEditor3",
"Effect": "Allow",
"Action": "amplify:*",
"Resource": [
"arn:aws:amplify:*:*:/apps/*/domains/*",
"arn:aws:amplify:*:*:apps/*/domains/*",
"arn:aws:amplify:*:*:/apps/*/branches/*/jobs/*",
"arn:aws:amplify:*:*:apps/*/branches/*/jobs/*"
]
}
]
}
Reassume test role, reload Amplify console--all features appear to be loading.
Expected behavior
Expected the IAM policy creation wizard to produce a policy capable of granting access to all Amplify actions and resources.
Additional context
Looks like there are some inconsistent resource ARN patterns in the codebase or in IAM, no idea how that all shakes out. Presumably need to standardize on whether or not to use a leading slash before apps in the pattern.
Sample code
I think it's pretty clear from the repro, but @ me if you need info.
Thanks for reporting the bug. The fix is on the way
What's the canonical pattern for the ARNs? /app or app?
arn:aws:amplify:
@nballenger we have pushed a fix. Can you please verify?
Looks like the policy gives access to everything. Thanks for the fix, I've updated my existing roles / groups to use the new policy. Leaving the issue open because I don't want to interfere with whatever your internal process is, but feel free to close--nothing further needed on my end.