@@ -68,6 +68,35 @@ Resources:
6868 SecurityGroups :
6969 - !Ref AppRunnerSecurityGroup
7070
71+ AppRunnerAccessRole :
72+ Type : AWS::IAM::Role
73+ Properties :
74+ RoleName : !Sub 'AppRunnerAccessRole-${Environment}'
75+ AssumeRolePolicyDocument :
76+ Version : ' 2012-10-17'
77+ Statement :
78+ - Effect : Allow
79+ Principal :
80+ Service : build.apprunner.amazonaws.com
81+ Action : sts:AssumeRole
82+ ManagedPolicyArns :
83+ - arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess
84+
85+ # App Runner Instance Role (for runtime)
86+ AppRunnerInstanceRole :
87+ Type : AWS::IAM::Role
88+ Properties :
89+ RoleName : !Sub 'AppRunnerInstanceRole-${Environment}'
90+ AssumeRolePolicyDocument :
91+ Version : ' 2012-10-17'
92+ Statement :
93+ - Effect : Allow
94+ Principal :
95+ Service : tasks.apprunner.amazonaws.com
96+ Action : sts:AssumeRole
97+ ManagedPolicyArns :
98+ - arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess
99+
71100 # App Runner Service
72101 AppRunnerService :
73102 Type : AWS::AppRunner::Service
@@ -79,24 +108,18 @@ Resources:
79108 ImageConfiguration :
80109 Port : ' 3001'
81110 RuntimeEnvironmentVariables :
82- - Name : NODE_ENV
83- Value : !Ref Environment
84- - Name : RDS_HOSTNAME
85- Value : !Ref RDSHostname
86- - Name : RDS_PORT
87- Value : !Ref RDSPort
88- - Name : RDS_DATABASE
89- Value : !Ref RDSDatabase
90- - Name : RDS_USERNAME
91- Value : !Ref RDSUsername
92- - Name : RDS_PASSWORD
93- Value : !Ref RDSPassword
94- - Name : DB_SSL
95- Value : ' true'
96- - Name : PORT
97- Value : ' 3001'
111+ NODE_ENV : !Ref Environment
112+ RDS_HOSTNAME : !Ref RDSHostname
113+ RDS_PORT : !Ref RDSPort
114+ RDS_DATABASE : !Ref RDSDatabase
115+ RDS_USERNAME : !Ref RDSUsername
116+ RDS_PASSWORD : !Ref RDSPassword
117+ DB_SSL : ' true'
118+ PORT : ' 3001'
98119 ImageRepositoryType : ECR
99120 AutoDeploymentsEnabled : true
121+ AuthenticationConfiguration :
122+ AccessRoleArn : !GetAtt AppRunnerAccessRole.Arn
100123 InstanceConfiguration :
101124 Cpu : " 0.25 vCPU"
102125 Memory : " 0.5 GB"
@@ -113,21 +136,6 @@ Resources:
113136 HealthyThreshold : 1
114137 UnhealthyThreshold : 5
115138
116- # IAM Role for App Runner Instance
117- AppRunnerInstanceRole :
118- Type : AWS::IAM::Role
119- Properties :
120- RoleName : !Sub 'AppRunnerInstanceRole-${Environment}'
121- AssumeRolePolicyDocument :
122- Version : ' 2012-10-17'
123- Statement :
124- - Effect : Allow
125- Principal :
126- Service : tasks.apprunner.amazonaws.com
127- Action : sts:AssumeRole
128- ManagedPolicyArns :
129- - arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess
130-
131139Outputs :
132140 ServiceUrl :
133141 Description : App Runner service URL
0 commit comments