DataSync location access test failed: could not perform S3:ListObjectsV2 #31259
Unanswered
matt-challe
asked this question in
Q&A
Replies: 1 comment
-
I think the order of resource creation doesn't get correctly determined so the S3 access check is performed before the policy is attached to the role. I was able to work around this by making the policy inline. I took the policy document from a default role that was available in the synthesised CloudFormation template. DataSyncRoleDefaultPolicyCF9D0BD2:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- s3:Abort*
- s3:DeleteObject*
- s3:GetBucket*
- s3:GetBucketLocation
- s3:GetObject
- s3:GetObject*
- s3:GetObjectTagging
- s3:List*
- s3:ListBucket
- s3:ListObjectsV2
- s3:PutObject
- s3:PutObjectAcl
- s3:PutObjectLegalHold
- s3:PutObjectRetention
- s3:PutObjectTagging
- s3:PutObjectVersionTagging
Effect: Allow
Resource:
- Fn::ImportValue: otto-core:ExportsOutputFnGetAttBotArtifactsBF93467EArn6A5C860D
- Fn::Join:
- ""
- - Fn::ImportValue: otto-core:ExportsOutputFnGetAttBotArtifactsBF93467EArn6A5C860D
- /*
- Action:
- elasticfilesystem:ClientMount
- elasticfilesystem:ClientRead
Effect: Allow
Resource:
Fn::ImportValue: otto-core:ExportsOutputFnGetAttTaskTemporaryFSE066DEF0ArnF57FF42E
Version: "2012-10-17"
PolicyName: DataSyncRoleDefaultPolicyCF9D0BD2
Roles:
- Ref: DataSyncRole90D44C0A
Metadata:
aws:cdk:path: otto-data-sync/DataSyncRole/DefaultPolicy/Resource datasync_role = iam.Role(
self,
"DataSyncRole",
assumed_by=iam.ServicePrincipal("datasync.amazonaws.com"),
# This policy has to be inline due to a race condition with the s3_location
inline_policies={
"DataSyncS3Policy": iam.PolicyDocument(
statements=[
iam.PolicyStatement(
actions=[
"s3:Abort*",
"s3:DeleteObject*",
"s3:GetBucket*",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:GetObject*",
"s3:GetObjectTagging",
"s3:List*",
"s3:ListBucket",
"s3:ListObjectsV2",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:PutObjectLegalHold",
"s3:PutObjectRetention",
"s3:PutObjectTagging",
"s3:PutObjectVersionTagging"
],
effect=iam.Effect.ALLOW,
resources=[
core_stack.artifact_bucket.bucket_arn,
f"{core_stack.artifact_bucket.bucket_arn}/*"
]
)
]
)
}
)
``` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create an S3 location for a DataSync Task and consistently running into the above error despite following AWS best practices . Note, S3:ListBucket is already given as a permission.
The error only occurs on "fresh" deploys where the stack is not already previously deployed successfully. My current workaround is to deploy granting the role S3 full access and then redeploy with the below policy. Below is the relevant portion of the python cdk code I am using.
Is this an AWS DataSync problem? Or a cdk bug?
Beta Was this translation helpful? Give feedback.
All reactions