@@ -2,7 +2,7 @@ Description: "Creates a web application with a static website using S3 and Cloud
22
33Metadata :
44 AWSToolsMetrics :
5- Rain : ' {"Version":"v1.21 .0","Experimental":true,"HasModules":true,"HasRainSection":true}'
5+ Rain : ' {"Version":"v1.22 .0","Experimental":true,"HasModules":true,"HasRainSection":true}'
66
77Parameters :
88 AppName :
@@ -243,31 +243,6 @@ Resources:
243243 Version : " 2012-10-17"
244244 Path : /
245245
246- SiteContentLogBucketAccessPolicy :
247- Type : AWS::S3::BucketPolicy
248- Properties :
249- Bucket : !Sub ${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
250- PolicyDocument :
251- Statement :
252- - Action : s3:PutObject
253- Condition :
254- ArnLike :
255- aws:SourceArn : !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
256- StringEquals :
257- aws:SourceAccount : !Ref AWS::AccountId
258- Bool :
259- aws:SecureTransport : false
260- Effect : Allow
261- Principal :
262- Service : logging.s3.amazonaws.com
263- AWS : ' *'
264- Resource :
265- - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
266- - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
267- - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
268- - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
269- Version : " 2012-10-17"
270-
271246 SiteContentBucketAccessPolicy :
272247 Type : AWS::S3::BucketPolicy
273248 Properties :
@@ -307,6 +282,31 @@ Resources:
307282 - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-replicas-${AWS::Region}-${AWS::AccountId}/*
308283 Version : " 2012-10-17"
309284
285+ SiteContentLogBucketAccessPolicy :
286+ Type : AWS::S3::BucketPolicy
287+ Properties :
288+ Bucket : !Sub ${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
289+ PolicyDocument :
290+ Statement :
291+ - Action : s3:PutObject
292+ Condition :
293+ ArnLike :
294+ aws:SourceArn : !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
295+ StringEquals :
296+ aws:SourceAccount : !Ref AWS::AccountId
297+ Bool :
298+ aws:SecureTransport : false
299+ Effect : Allow
300+ Principal :
301+ Service : logging.s3.amazonaws.com
302+ AWS : ' *'
303+ Resource :
304+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
305+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
306+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}
307+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-content-logs-${AWS::Region}-${AWS::AccountId}/*
308+ Version : " 2012-10-17"
309+
310310 SiteCloudFrontLogsLogBucket :
311311 Type : AWS::S3::Bucket
312312 Metadata :
@@ -450,35 +450,28 @@ Resources:
450450 Version : " 2012-10-17"
451451 Path : /
452452
453- SiteCloudFrontLogsLogBucketAccessPolicy :
453+ SiteCloudFrontLogsBucketAccessPolicy :
454454 Type : AWS::S3::BucketPolicy
455455 Properties :
456- Bucket : !Sub ${AppName}-cflogs-logs- ${AWS::Region}-${AWS::AccountId}
456+ Bucket : !Sub ${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}
457457 PolicyDocument :
458458 Statement :
459- - Action : s3:PutObject
459+ - Action : s3:*
460460 Condition :
461- ArnLike :
462- aws:SourceArn : !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
463- StringEquals :
464- aws:SourceAccount : !Ref AWS::AccountId
465461 Bool :
466462 aws:SecureTransport : false
467- Effect : Allow
463+ Effect : Deny
468464 Principal :
469- Service : logging.s3.amazonaws.com
470465 AWS : ' *'
471466 Resource :
472- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}
473- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
474- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}
475- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
467+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}
468+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}/*
476469 Version : " 2012-10-17"
477470
478- SiteCloudFrontLogsBucketAccessPolicy :
471+ SiteCloudFrontLogsReplicaBucketAccessPolicy :
479472 Type : AWS::S3::BucketPolicy
480473 Properties :
481- Bucket : !Sub ${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}
474+ Bucket : !Sub ${AppName}-cflogs-replicas- ${AWS::Region}-${AWS::AccountId}
482475 PolicyDocument :
483476 Statement :
484477 - Action : s3:*
@@ -489,26 +482,33 @@ Resources:
489482 Principal :
490483 AWS : ' *'
491484 Resource :
492- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}
493- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-${AWS::Region}-${AWS::AccountId}/*
485+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-replicas- ${AWS::Region}-${AWS::AccountId}
486+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-replicas- ${AWS::Region}-${AWS::AccountId}/*
494487 Version : " 2012-10-17"
495488
496- SiteCloudFrontLogsReplicaBucketAccessPolicy :
489+ SiteCloudFrontLogsLogBucketAccessPolicy :
497490 Type : AWS::S3::BucketPolicy
498491 Properties :
499- Bucket : !Sub ${AppName}-cflogs-replicas -${AWS::Region}-${AWS::AccountId}
492+ Bucket : !Sub ${AppName}-cflogs-logs -${AWS::Region}-${AWS::AccountId}
500493 PolicyDocument :
501494 Statement :
502- - Action : s3:*
495+ - Action : s3:PutObject
503496 Condition :
497+ ArnLike :
498+ aws:SourceArn : !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
499+ StringEquals :
500+ aws:SourceAccount : !Ref AWS::AccountId
504501 Bool :
505502 aws:SecureTransport : false
506- Effect : Deny
503+ Effect : Allow
507504 Principal :
505+ Service : logging.s3.amazonaws.com
508506 AWS : ' *'
509507 Resource :
510- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-replicas-${AWS::Region}-${AWS::AccountId}
511- - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-replicas-${AWS::Region}-${AWS::AccountId}/*
508+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}
509+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
510+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}
511+ - !Sub arn:${AWS::Partition}:s3:::${AppName}-cflogs-logs-${AWS::Region}-${AWS::AccountId}/*
512512 Version : " 2012-10-17"
513513
514514 CognitoUserPool :
@@ -552,15 +552,49 @@ Resources:
552552 SupportedIdentityProviders :
553553 - COGNITO
554554
555+ RestApi :
556+ Type : AWS::ApiGateway::RestApi
557+ Properties :
558+ Name : !Ref AppName
559+
560+ RestApiDeployment :
561+ Type : AWS::ApiGateway::Deployment
562+ DependsOn :
563+ - TestResourceGet
564+ - TestResourceOptions
565+ - JwtResourceGet
566+ - JwtResourceOptions
567+ Metadata :
568+ Version : 2
569+ Properties :
570+ RestApiId : !Ref RestApi
571+
572+ RestApiStage :
573+ Type : AWS::ApiGateway::Stage
574+ Properties :
575+ RestApiId : !Ref RestApi
576+ DeploymentId : !Ref RestApiDeployment
577+ StageName : prod
578+
579+ RestApiAuthorizer :
580+ Type : AWS::ApiGateway::Authorizer
581+ Properties :
582+ IdentitySource : method.request.header.authorization
583+ Name : CognitoApiAuthorizer
584+ ProviderARNs :
585+ - !GetAtt CognitoUserPool.Arn
586+ RestApiId : !Ref RestApi
587+ Type : COGNITO_USER_POOLS
588+
555589 TestResourceHandler :
556590 Type : AWS::Lambda::Function
557591 Properties :
558592 Handler : bootstrap
559593 FunctionName : !Sub ${AppName}-test-handler
560594 Runtime : provided.al2023
561595 Code :
562- S3Bucket : rain-artifacts-755952356119 -us-east-1
563- S3Key : 77a966929bda29d575910093c38c9c1234ce19121144b0efa1a3e0b77155dc21
596+ S3Bucket : rain-artifacts-207567786752 -us-east-1
597+ S3Key : d4e37950015c58dc7c4e9e0ac7ab1dd41ab4d914a44e92244758b966573d166e
564598 Role : !GetAtt TestResourceHandlerRole.Arn
565599 Environment :
566600 Variables :
@@ -629,15 +663,48 @@ Resources:
629663 Type : AWS_PROXY
630664 Uri : !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TestResourceHandler.Arn}/invocations
631665
666+ TestDataTable :
667+ Type : AWS::DynamoDB::Table
668+ Properties :
669+ BillingMode : PAY_PER_REQUEST
670+ TableName : !Sub ${AppName}-test
671+ AttributeDefinitions :
672+ - AttributeName : id
673+ AttributeType : S
674+ KeySchema :
675+ - AttributeName : id
676+ KeyType : HASH
677+
678+ TestDataLambdaPolicy :
679+ Type : AWS::IAM::RolePolicy
680+ Metadata :
681+ Comment : This resource is created only if the LambdaRoleArn is set
682+ Properties :
683+ PolicyDocument :
684+ Statement :
685+ - Action :
686+ - dynamodb:BatchGetItem
687+ - dynamodb:GetItem
688+ - dynamodb:Query
689+ - dynamodb:Scan
690+ - dynamodb:BatchWriteItem
691+ - dynamodb:PutItem
692+ - dynamodb:UpdateItem
693+ Effect : Allow
694+ Resource :
695+ - !GetAtt TestDataTable.Arn
696+ PolicyName : !Sub ${AppName}-test-policy
697+ RoleName : !Ref TestResourceHandlerRole
698+
632699 JwtResourceHandler :
633700 Type : AWS::Lambda::Function
634701 Properties :
635702 Handler : bootstrap
636703 FunctionName : !Sub ${AppName}-jwt-handler
637704 Runtime : provided.al2023
638705 Code :
639- S3Bucket : rain-artifacts-755952356119 -us-east-1
640- S3Key : 7bde57b13984589f9359b01fc4282afc17a16d166953da50f663d0b5212c1ac7
706+ S3Bucket : rain-artifacts-207567786752 -us-east-1
707+ S3Key : 9e3528cc44b150ec0457f13fa6215b920fb2fac546df321a74f23e06014d3d71
641708 Role : !GetAtt JwtResourceHandlerRole.Arn
642709 Environment :
643710 Variables :
@@ -710,73 +777,6 @@ Resources:
710777 Type : AWS_PROXY
711778 Uri : !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${JwtResourceHandler.Arn}/invocations
712779
713- RestApi :
714- Type : AWS::ApiGateway::RestApi
715- Properties :
716- Name : !Ref AppName
717-
718- RestApiDeployment :
719- Type : AWS::ApiGateway::Deployment
720- DependsOn :
721- - TestResourceGet
722- - TestResourceOptions
723- - JwtResourceGet
724- - JwtResourceOptions
725- Metadata :
726- Version : 2
727- Properties :
728- RestApiId : !Ref RestApi
729-
730- RestApiStage :
731- Type : AWS::ApiGateway::Stage
732- Properties :
733- RestApiId : !Ref RestApi
734- DeploymentId : !Ref RestApiDeployment
735- StageName : prod
736-
737- RestApiAuthorizer :
738- Type : AWS::ApiGateway::Authorizer
739- Properties :
740- IdentitySource : method.request.header.authorization
741- Name : CognitoApiAuthorizer
742- ProviderARNs :
743- - !GetAtt CognitoUserPool.Arn
744- RestApiId : !Ref RestApi
745- Type : COGNITO_USER_POOLS
746-
747- TestDataTable :
748- Type : AWS::DynamoDB::Table
749- Properties :
750- BillingMode : PAY_PER_REQUEST
751- TableName : !Sub ${AppName}-test
752- AttributeDefinitions :
753- - AttributeName : id
754- AttributeType : S
755- KeySchema :
756- - AttributeName : id
757- KeyType : HASH
758-
759- TestDataLambdaPolicy :
760- Type : AWS::IAM::RolePolicy
761- Metadata :
762- Comment : This resource is created only if the LambdaRoleArn is set
763- Properties :
764- PolicyDocument :
765- Statement :
766- - Action :
767- - dynamodb:BatchGetItem
768- - dynamodb:GetItem
769- - dynamodb:Query
770- - dynamodb:Scan
771- - dynamodb:BatchWriteItem
772- - dynamodb:PutItem
773- - dynamodb:UpdateItem
774- Effect : Allow
775- Resource :
776- - !GetAtt TestDataTable.Arn
777- PolicyName : !Sub ${AppName}-test-policy
778- RoleName : !Ref TestResourceHandlerRole
779-
780780Outputs :
781781 SiteURL :
782782 Value : !Sub https://${SiteDistribution.DomainName}
0 commit comments