|
| 1 | +# customized version of the docs/pds-bucket-cf.yml template for creating the its-live-data bucket. |
| 2 | +# Customization includes a log bucket and a logging configuration and S3 inventory configuration on the dataset bucket. |
| 3 | +--- |
| 4 | +AWSTemplateFormatVersion: '2010-09-09' |
| 5 | +Description: This template creates the AWS infrastructure to publish a public data set on S3. It creates a publicly-accessible S3 bucket for the dataset, enables CloudWatch Metrics for the dataset bucket, and creates a public SQS and Lambda subscribable SNS Topic. Additionally, it includes a log bucket, logging configuration, and an inventory configuration. |
| 6 | + |
| 7 | +Parameters: |
| 8 | + DataSetName: |
| 9 | + AllowedPattern: '[a-z0-9\.\-]*' |
| 10 | + ConstraintDescription: may only contain lowercase letters, numbers, and ., or - characters |
| 11 | + Description: "The name of the dataset's S3 bucket. This will be used to create the dataset S3 bucket." |
| 12 | + MaxLength: '250' |
| 13 | + MinLength: '1' |
| 14 | + Type: String |
| 15 | + |
| 16 | +Resources: |
| 17 | + SNSTopic: |
| 18 | + Properties: |
| 19 | + TopicName: !Join [ "", [ !Join [ "", !Split [ ".", !Ref DataSetName ] ], "-object_created" ] ] |
| 20 | + Type: AWS::SNS::Topic |
| 21 | + |
| 22 | + SNSTopicPolicy: |
| 23 | + Properties: |
| 24 | + Topics: |
| 25 | + - !Ref SNSTopic |
| 26 | + PolicyDocument: |
| 27 | + Version: '2012-10-17' |
| 28 | + Statement: |
| 29 | + - Sid: allowS3BucketToPublish |
| 30 | + Effect: Allow |
| 31 | + Action: |
| 32 | + - sns:Publish |
| 33 | + Resource: !Ref SNSTopic |
| 34 | + Principal: |
| 35 | + Service: s3.amazonaws.com |
| 36 | + Condition: |
| 37 | + ArnLike: |
| 38 | + aws:SourceArn: !Sub arn:aws:s3:::${DataSetName} |
| 39 | + StringEquals: |
| 40 | + aws:SourceAccount: !Ref AWS::AccountId |
| 41 | + - Sid: allowOnlySQSandLambdaSubscription |
| 42 | + Effect: Allow |
| 43 | + Action: |
| 44 | + - sns:Subscribe |
| 45 | + Resource: !Ref SNSTopic |
| 46 | + Principal: |
| 47 | + AWS: "*" |
| 48 | + Condition: |
| 49 | + StringEquals: |
| 50 | + SNS:Protocol: |
| 51 | + - sqs |
| 52 | + - lambda |
| 53 | + Type: AWS::SNS::TopicPolicy |
| 54 | + |
| 55 | + LogBucket: |
| 56 | + Type: AWS::S3::Bucket |
| 57 | + Properties: |
| 58 | + PublicAccessBlockConfiguration: |
| 59 | + BlockPublicAcls: True |
| 60 | + IgnorePublicAcls: True |
| 61 | + BlockPublicPolicy: True |
| 62 | + RestrictPublicBuckets: True |
| 63 | + BucketEncryption: |
| 64 | + ServerSideEncryptionConfiguration: |
| 65 | + - ServerSideEncryptionByDefault: |
| 66 | + SSEAlgorithm: AES256 |
| 67 | + BucketKeyEnabled: true |
| 68 | + OwnershipControls: |
| 69 | + Rules: |
| 70 | + - ObjectOwnership: BucketOwnerEnforced |
| 71 | + LifecycleConfiguration: |
| 72 | + Rules: |
| 73 | + - Id: ExpireAll |
| 74 | + Status: Enabled |
| 75 | + ExpirationInDays: 30 |
| 76 | + - Id: ExpireVelocityInventory |
| 77 | + Prefix: 'inventory/velocity_image_pair/' |
| 78 | + Status: Enabled |
| 79 | + ExpirationInDays: 3 |
| 80 | + LogBucketPolicy: |
| 81 | + Type: AWS::S3::BucketPolicy |
| 82 | + Properties: |
| 83 | + Bucket: !Ref LogBucket |
| 84 | + PolicyDocument: |
| 85 | + Version: '2012-10-17' |
| 86 | + Statement: |
| 87 | + - Effect: Allow |
| 88 | + Principal: |
| 89 | + Service: |
| 90 | + - logging.s3.amazonaws.com |
| 91 | + - s3.amazonaws.com |
| 92 | + Action: s3:PutObject |
| 93 | + Resource: !Sub "${LogBucket.Arn}/*" |
| 94 | + Condition: |
| 95 | + ArnLike: |
| 96 | + "aws:SourceArn": !GetAtt DataSetBucket.Arn |
| 97 | + StringEquals: |
| 98 | + "aws:SourceAccount": !Ref AWS::AccountId |
| 99 | + |
| 100 | + DataSetBucket: |
| 101 | + DeletionPolicy: Retain |
| 102 | + UpdateReplacePolicy: Delete |
| 103 | + DependsOn: |
| 104 | + - SNSTopicPolicy |
| 105 | + Properties: |
| 106 | + BucketName: !Ref DataSetName |
| 107 | + LoggingConfiguration: |
| 108 | + DestinationBucketName: !Ref LogBucket |
| 109 | + TargetObjectKeyFormat: |
| 110 | + PartitionedPrefix: |
| 111 | + PartitionDateSource: EventTime |
| 112 | + MetricsConfigurations: |
| 113 | + - Id: EntireBucket |
| 114 | + InventoryConfigurations: |
| 115 | + - Id: VelocityGranuleInventory |
| 116 | + Destination: |
| 117 | + BucketAccountId: !Ref AWS::AccountId |
| 118 | + BucketArn: !GetAtt LogBucket.Arn |
| 119 | + Format: Parquet |
| 120 | + Prefix: inventory/velocity_image_pair |
| 121 | + Enabled: true |
| 122 | + Prefix: velocity_image_pair/ |
| 123 | + IncludedObjectVersions: Current |
| 124 | + OptionalFields: |
| 125 | + - Size |
| 126 | + - LastModifiedDate |
| 127 | + - StorageClass |
| 128 | + - IntelligentTieringAccessTier |
| 129 | + ScheduleFrequency: Daily |
| 130 | + - Id: BucketInventory |
| 131 | + Destination: |
| 132 | + BucketAccountId: !Ref AWS::AccountId |
| 133 | + BucketArn: !GetAtt LogBucket.Arn |
| 134 | + Format: Parquet |
| 135 | + Prefix: inventory/all |
| 136 | + Enabled: true |
| 137 | + IncludedObjectVersions: Current |
| 138 | + OptionalFields: |
| 139 | + - Size |
| 140 | + - LastModifiedDate |
| 141 | + - StorageClass |
| 142 | + - IntelligentTieringAccessTier |
| 143 | + ScheduleFrequency: Weekly |
| 144 | + LifecycleConfiguration: |
| 145 | + Rules: |
| 146 | + - Id: IntelligentTieringRule |
| 147 | + Status: Enabled |
| 148 | + Transitions: |
| 149 | + - TransitionInDays: '0' |
| 150 | + StorageClass: INTELLIGENT_TIERING |
| 151 | + - Id: AbortIncompleteMultipartUploadRule |
| 152 | + Status: Enabled |
| 153 | + AbortIncompleteMultipartUpload: |
| 154 | + DaysAfterInitiation: 7 |
| 155 | + NotificationConfiguration: |
| 156 | + TopicConfigurations: |
| 157 | + - Event: "s3:ObjectCreated:*" |
| 158 | + Topic: !Ref SNSTopic |
| 159 | + PublicAccessBlockConfiguration: |
| 160 | + BlockPublicPolicy: false |
| 161 | + RestrictPublicBuckets: false |
| 162 | + CorsConfiguration: |
| 163 | + CorsRules: |
| 164 | + - AllowedHeaders: |
| 165 | + - "*" |
| 166 | + AllowedMethods: |
| 167 | + - HEAD |
| 168 | + - GET |
| 169 | + AllowedOrigins: |
| 170 | + - "*" |
| 171 | + ExposedHeaders: |
| 172 | + - ETag |
| 173 | + - x-amz-meta-custom-header |
| 174 | + MaxAge: 3000 |
| 175 | + Type: AWS::S3::Bucket |
| 176 | + |
| 177 | + DataSetBucketPolicy: |
| 178 | + Properties: |
| 179 | + Bucket: !Ref DataSetBucket |
| 180 | + PolicyDocument: |
| 181 | + Statement: |
| 182 | + - Action: |
| 183 | + - s3:List* |
| 184 | + - s3:Get* |
| 185 | + Effect: Allow |
| 186 | + Principal: "*" |
| 187 | + Resource: |
| 188 | + - !Sub arn:aws:s3:::${DataSetBucket}/* |
| 189 | + - !Sub arn:aws:s3:::${DataSetBucket} |
| 190 | + Condition: |
| 191 | + Bool: |
| 192 | + aws:SecureTransport: true |
| 193 | + Type: AWS::S3::BucketPolicy |
| 194 | + |
| 195 | +Outputs: |
| 196 | + DataBucket: |
| 197 | + Description: "S3 data bucket name" |
| 198 | + Value: !Sub ${DataSetBucket} |
| 199 | + LogBucket: |
| 200 | + Description: "S3 log bucket name" |
| 201 | + Value: !Sub ${LogBucket} |
| 202 | + SNSTopic: |
| 203 | + Description: "SQS and Lambda subscribable SNS Topic" |
| 204 | + Value: !Ref SNSTopic |
0 commit comments