-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-apprunner-alpha: accessRole
prop doesn't work
#32974
Comments
Hi @garysassano , thanks for reaching out. I am able to reproduce the scenario with the given code - const apprunnerInstanceRole = new Role(this, "ApprunnerInstanceRole", {
assumedBy: new ServicePrincipal("tasks.apprunner.amazonaws.com"),
});
const apprunnerAccessRole = new Role(this, "ApprunnerAccessRole", {
assumedBy: new ServicePrincipal("build.apprunner.amazonaws.com"),
managedPolicies: [
{
managedPolicyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
},
],
});
const servicenew = new apprunner.Service(this, "ApacheService", {
accessRole: apprunnerAccessRole,
instanceRole: apprunnerInstanceRole,
source: apprunner.Source.fromEcrPublic({
imageIdentifier: "public.ecr.aws/docker/library/httpd:bookworm",
imageConfiguration: {
port: 80,
},
}),
});
} Here is the output in console when deployed - Looks like the issue exists here -
if you leave it Marking it as P3 as default role creation exists but code should also take passed value into consideration. Contribution from the community are also welcome for resolution of this bug. |
Since an access role is only set when ECR is private, this seems to be the intended behavior.
The docs states the following:
Do we need to set an access role even when using ECR Public? |
@mazyu36 My initial implementation actually used an ECR private registry configured with a pull-through cache for Docker Hub. The outcome was identical. I created a minimal reproducible code block using the Apache image solely to illustrate the issue. |
To clarify, the default access role cannot be used because you need to create an ECR registry permission that enables the IAM role used by App Runner to pull images via the pull-through cache. Here's an example implementation: apprunnerInstanceRole.addToPrincipalPolicy(
new PolicyStatement({
actions: ["ecr:*"],
resources: [
`arn:aws:ecr:${this.region}:${this.account}:repository/docker-hub/*`,
],
}),
);
const registryPolicy = new CfnRegistryPolicy(this, "EcrRegistryPolicy", {
policyText: {
Version: "2012-10-17",
Statement: [
{
Sid: "AllowPullThroughCache",
Effect: "Allow",
Principal: {
AWS: apprunnerAccessRole.roleArn,
},
Action: ["ecr:*"],
Resource:
"arn:aws:ecr:${this.region}:${this.account}:repository/docker-hub/",
},
],
},
}); Unfortunately, there's no built-in method to modify the access role policy directly. Currently, you only have the option to use It would be much better to have more idiomatic and self-explanatory methods like |
Describe the bug
The
accessRole
prop in theService
L2 construct doesn't work. If you try to set it, it gets ignored.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expected the App Runner service to be created with the configured access role, like for this service I manually created from AWS Console:
Current Behavior
The App Runner service gets deployed without the configured access role:
Reproduction Steps
Deploy the following Stack:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.175.1
Framework Version
No response
Node.js Version
22.12.0
OS
Ubuntu 24.04.1
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: