Skip to content

Commit 34bbfe6

Browse files
committed
Create S3 bucket for file uploads
1 parent 4a402db commit 34bbfe6

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

backend/src/iac/backend-stack.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -553,36 +553,34 @@ export class BackendStack extends cdk.Stack {
553553
const uploadPolicy = new iam.PolicyStatement({
554554
effect: iam.Effect.ALLOW,
555555
actions: ['s3:PutObject', 's3:GetObject', 's3:DeleteObject'],
556-
resources: [
557-
`${uploadBucket.bucketArn}/*`,
558-
],
556+
resources: [`${uploadBucket.bucketArn}/*`],
559557
conditions: {
560558
// Restrict uploads to PDF and JPG files
561-
'StringLike': {
562-
's3:x-amz-content-type': [
563-
'application/pdf',
564-
'image/jpeg',
565-
'image/jpg'
566-
]
567-
}
568-
}
559+
StringLike: {
560+
's3:x-amz-content-type': ['application/pdf', 'image/jpeg', 'image/jpg'],
561+
},
562+
},
569563
});
570564

571565
// Create an IAM role for authenticated users
572-
const authenticatedRole = new iam.Role(this, `${appName}AuthenticatedRole-${props.environment}`, {
573-
assumedBy: new iam.FederatedPrincipal(
574-
'cognito-identity.amazonaws.com',
575-
{
576-
StringEquals: {
577-
'cognito-identity.amazonaws.com:aud': userPool.userPoolId,
578-
},
579-
'ForAnyValue:StringLike': {
580-
'cognito-identity.amazonaws.com:amr': 'authenticated',
566+
const authenticatedRole = new iam.Role(
567+
this,
568+
`${appName}AuthenticatedRole-${props.environment}`,
569+
{
570+
assumedBy: new iam.FederatedPrincipal(
571+
'cognito-identity.amazonaws.com',
572+
{
573+
StringEquals: {
574+
'cognito-identity.amazonaws.com:aud': userPool.userPoolId,
575+
},
576+
'ForAnyValue:StringLike': {
577+
'cognito-identity.amazonaws.com:amr': 'authenticated',
578+
},
581579
},
582-
},
583-
'sts:AssumeRoleWithWebIdentity'
584-
),
585-
});
580+
'sts:AssumeRoleWithWebIdentity',
581+
),
582+
},
583+
);
586584

587585
// Attach the upload policy to the authenticated role
588586
authenticatedRole.addToPolicy(uploadPolicy);

0 commit comments

Comments
 (0)