Stack to create a S3 bucket

Stack to create a S3 bucket

Cloudformation:

	
		Description: Stack to create a S3 bucket for only read files.

		Parameters:
		  Stage:
			Description: Environment Name
			Type: String

		  BucketName:
			Type: String
			Description: The bucket name

		  OriginURL:
			Description: Origin url name
			Type: String
			
		Resources:
		  S3FilesBucket:
			Type: AWS::S3::Bucket
			Properties:
			  BucketName: !Ref BucketName
			  VersioningConfiguration:
				Status: Enabled
			  BucketEncryption:
				ServerSideEncryptionConfiguration:
				  - ServerSideEncryptionByDefault:
					  SSEAlgorithm: AES256
			  PublicAccessBlockConfiguration:
				BlockPublicAcls : true
				BlockPublicPolicy : true
				IgnorePublicAcls : true
				RestrictPublicBuckets : true
			  CorsConfiguration:
				CorsRules:
				  - AllowedHeaders:
					  - x-amz-*
					AllowedMethods:
					  - PUT
					AllowedOrigins:
					  - !Ref OriginURL
					ExposedHeaders:
					  - Connection
					  - Server
					  - Date
					Id: myCORSRuleId
					MaxAge: 1800
			  Tags: 
				- Key: "key"
				  Value: "value"

		  BucketPolicy:
			Type: AWS::S3::BucketPolicy
			Properties:
			  Bucket: !Ref S3FilesBucket
			  PolicyDocument:
				Statement:
				  - Action:
					  - 's3:GetObject'
					  - 's3:PutObject'
					Effect: Allow
					Resource: !Join ['', ['arn:aws:s3:::', !Ref S3FilesBucket, '/*']]
					Principal:
					  AWS:
						- !Sub "arn:aws:iam::${AWS::AccountId}:root"
	

Comentarios

Entradas más populares de este blog

Ejemplo Log4j 2 en JAVA | Log4j 2 en Springboot | Configuración Log4j 2 | Log4j 2 in SpringBoot| Example Log4j 2 in SpringBoot | Configuring Log4j 2

Python: Inyección de dependencias

GOlang con Docker | GOlang with Docker | GO con Docker | GO with Docker