Parameters: App: Type: String Description: Your application's name. Env: Type: String Description: The environment name your service, job, or workflow is being deployed to. Name: Type: String Description: Your workload's name. Resources: {{logicalIDSafe .Name}}Bucket: Metadata: 'aws:copilot:description': 'An Amazon S3 bucket to store and retrieve objects for {{.Name}}' Type: AWS::S3::Bucket Properties: AccessControl: Private BucketEncryption: ServerSideEncryptionConfiguration: - ServerSideEncryptionByDefault: SSEAlgorithm: AES256 PublicAccessBlockConfiguration: BlockPublicAcls: true BlockPublicPolicy: true IgnorePublicAcls: true RestrictPublicBuckets: true OwnershipControls: Rules: - ObjectOwnership: BucketOwnerEnforced {{logicalIDSafe .Name}}BucketPolicy: Metadata: 'aws:copilot:description': 'A bucket policy to deny unencrypted access to the bucket and its contents' Type: AWS::S3::BucketPolicy DeletionPolicy: Retain Properties: PolicyDocument: Version: '2012-10-17' Statement: - Sid: ForceHTTPS Effect: Deny Principal: '*' Action: 's3:*' Resource: - !Sub ${ {{logicalIDSafe .Name}}Bucket.Arn}/* - !Sub ${ {{logicalIDSafe .Name}}Bucket.Arn} Condition: Bool: "aws:SecureTransport": false Bucket: !Ref {{logicalIDSafe .Name}}Bucket {{logicalIDSafe .Name}}AccessPolicy: Metadata: 'aws:copilot:description': 'An IAM ManagedPolicy for your service to access the {{.Name}} bucket' Type: AWS::IAM::ManagedPolicy Properties: Description: !Sub - Grants CRUD access to the S3 bucket ${Bucket} - { Bucket: !Ref {{logicalIDSafe .Name}}Bucket } PolicyDocument: Version: '2012-10-17' Statement: - Sid: S3ObjectActions Effect: Allow Action: - s3:GetObject - s3:PutObject - s3:PutObjectACL - s3:PutObjectTagging - s3:DeleteObject - s3:RestoreObject Resource: !Sub ${ {{logicalIDSafe .Name}}Bucket.Arn}/* - Sid: S3ListAction Effect: Allow Action: s3:ListBucket Resource: !Sub ${ {{logicalIDSafe .Name}}Bucket.Arn} Outputs: {{envVarName .Name}}: Description: "The name of a user-defined bucket." Value: !Ref {{logicalIDSafe .Name}}Bucket {{logicalIDSafe .Name}}AccessPolicy: Description: "The IAM::ManagedPolicy to attach to the task role" Value: !Ref {{logicalIDSafe .Name}}AccessPolicy