Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3741,6 +3741,33 @@
},
"Sid": "/temp_ReadWrite"
},
{
"Action": "s3:GetObject*",
"Condition": {
"StringLike": {
"aws:PrincipalArn": "arn:aws:iam::test-account:role/datazone_usr_role_*"
}
},
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketprojectAACC6DD8",
"Arn"
]
},
"/deployment/*"
]
]
},
"Sid": "SmusUserRoleDeploymentRead"
},
{
"Action": [
"s3:PutObject*",
Expand Down Expand Up @@ -3863,7 +3890,8 @@
"projectdeploymentrole542A1AAB",
"Arn"
]
}
},
"arn:aws:iam::test-account:role/datazone_usr_role_*"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,33 @@
},
"Sid": "/temp_ReadWrite"
},
{
"Action": "s3:GetObject*",
"Condition": {
"StringLike": {
"aws:PrincipalArn": "arn:aws:iam::test-account:role/datazone_usr_role_*"
}
},
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketprojectAACC6DD8",
"Arn"
]
},
"/deployment/*"
]
]
},
"Sid": "SmusUserRoleDeploymentRead"
},
{
"Action": [
"s3:PutObject*",
Expand Down Expand Up @@ -2398,7 +2425,8 @@
"projectdeploymentrole542A1AAB",
"Arn"
]
}
},
"arn:aws:iam::test-account:role/datazone_usr_role_*"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,33 @@
},
"Sid": "/temp_ReadWrite"
},
{
"Action": "s3:GetObject*",
"Condition": {
"StringLike": {
"aws:PrincipalArn": "arn:aws:iam::test-account:role/datazone_usr_role_*"
}
},
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketprojectAACC6DD8",
"Arn"
]
},
"/deployment/*"
]
]
},
"Sid": "SmusUserRoleDeploymentRead"
},
{
"Action": [
"s3:PutObject*",
Expand Down Expand Up @@ -1632,7 +1659,8 @@
"projectdeploymentrole542A1AAB",
"Arn"
]
}
},
"arn:aws:iam::test-account:role/datazone_usr_role_*"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,33 @@
},
"Sid": "/temp_ReadWrite"
},
{
"Action": "s3:GetObject*",
"Condition": {
"StringLike": {
"aws:PrincipalArn": "arn:aws:iam::test-account:role/datazone_usr_role_*"
}
},
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketprojectAACC6DD8",
"Arn"
]
},
"/deployment/*"
]
]
},
"Sid": "SmusUserRoleDeploymentRead"
},
{
"Action": [
"s3:PutObject*",
Expand Down Expand Up @@ -1901,7 +1928,8 @@
"projectdeploymentrole542A1AAB",
"Arn"
]
}
},
"arn:aws:iam::test-account:role/datazone_usr_role_*"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1501,12 +1501,25 @@ export class DataOpsProjectL3Construct extends MdaaL3Construct {
});
tempPolicy.statements().forEach(statement => projectBucket.addToResourcePolicy(statement));

// SMUS creates per-user roles named datazone_usr_role_<projectId>_<userId> at session time.
// These are not known to MDAA at deploy time so they cannot be added to roleExcludeIds.
const smusUserRoleArnPattern = `arn:aws:iam::${this.account}:role/datazone_usr_role_*`;
const smusUserRoleDeploymentRead = new PolicyStatement({
sid: 'SmusUserRoleDeploymentRead',
effect: Effect.ALLOW,
actions: RestrictObjectPrefixToRoles.READ_ACTIONS,
resources: [projectBucket.arnForObjects('deployment/*')],
conditions: { StringLike: { 'aws:PrincipalArn': smusUserRoleArnPattern } },
});
smusUserRoleDeploymentRead.addAnyPrincipal();
projectBucket.addToResourcePolicy(smusUserRoleDeploymentRead);

//Default Deny Policy
//Any role not specified in props is explicitely denied access to the bucket
const bucketRestrictPolicy = new RestrictBucketToRoles({
s3Bucket: projectBucket,
roleExcludeIds: [...this.getAllRoleIds(), lakeFormationRole.roleId, datazoneUserRole.roleId],
principalExcludes: [projectDeploymentRole.roleArn],
principalExcludes: [projectDeploymentRole.roleArn, smusUserRoleArnPattern],
});
projectBucket.addToResourcePolicy(bucketRestrictPolicy.denyStatement);
projectBucket.addToResourcePolicy(bucketRestrictPolicy.allowStatement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,29 @@ describe('MDAA Compliance Stack Tests', () => {
});
});

test('SmusUserRoleDeploymentRead', () => {
template.hasResourceProperties('AWS::S3::BucketPolicy', {
PolicyDocument: {
Statement: Match.arrayWith([
Match.objectLike({
Sid: 'SmusUserRoleDeploymentRead',
Effect: 'Allow',
Action: 's3:GetObject*',
Principal: { AWS: '*' },
Resource: {
'Fn::Join': ['', [{ 'Fn::GetAtt': ['BucketprojectAACC6DD8', 'Arn'] }, '/deployment/*']],
},
Condition: {
StringLike: {
'aws:PrincipalArn': Match.stringLikeRegexp('datazone_usr_role_\\*$'),
},
},
}),
]),
},
});
});

test('DeploymentRoleReadWrite', () => {
template.hasResourceProperties('AWS::S3::BucketPolicy', {
PolicyDocument: {
Expand Down