-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: policy to access the S3 marts bucket #190
Conversation
S3martsBucketAccessPolicy: | ||
Type: AWS::IAM::Policy | ||
Properties: | ||
PolicyName: s3martsBucketPolicy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to capital "S3"
Redundant since the policy was changed to a ManagedPolicy in 843eb60
PolicyName: s3martsBucketPolicy | ||
# Attach this policy to the TaskRole provided by Copilot. | ||
Roles: | ||
- "pems-dev-streamlit-TaskRole-5Zuwi15thMkN" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modify this so that the policy is also added to test
and prod
Redundant since the policy was changed to a ManagedPolicy in 843eb60
58fb003
to
c4c3ea0
Compare
it turns out that the parameter "TaskRole" in the template is not being set by Copilot, so it does not resolve. Because of this, we need to hardcode the name of the Task role.
given how AWS Copilot works, it is more convenient to use a managed policy since it is automatically attached to the Task role.
c4c3ea0
to
843eb60
Compare
@thekaveman I updated how we are giving permissions to the Task role that runs the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incredible! Using a Managed Policy seems like the best approach 👍
Closes #185
Add a policy (as a Copilot addon) for accessing the S3 marts bucket from the ECS
streamlit
task via its Task role.Notes
Using a
ManagedPolicy
is the most straightforward way to add permissions to the Copilot-created ECSstreamlit
TaskRole
.To see how the CloudFormation templates created by Copilot will look like when adding the
s3-marts-access-policy
addon, runfrom the
infra
folder. The command will create 3 files (parameters, main stack template, and addon stack template) ininfra
. The addon stack template is essentially the template in this PR (with a few formatting changes) and the main stack template and parameters are what the Copilot CLI will produce to send to CloudFormation to create the stack. The key section of the main stack, where the link is made with the permissions defined in the addon, is shown belowNote that there is no mention of the environment in the addon stack because accessing the S3 marts bucket is not dependent on the environment, all environments will access the same S3 bucket with the same permissions.