@@ -85,9 +85,25 @@ export class AlloraStack extends cdk.Stack {
85
85
ec2UserData . addCommands ( modifiedUserData ) ;
86
86
87
87
// Getting the snapshot bucket name and IAM role ARN from the common stack
88
- const importedInstanceRoleArn = cdk . Fn . importValue ( "EdgeNodeInstanceRoleArn" ) ;
88
+ const instanceRole = new iam . Role ( this , "node-role" , {
89
+ assumedBy : new iam . ServicePrincipal ( "ec2.amazonaws.com" ) ,
90
+ managedPolicies : [
91
+ iam . ManagedPolicy . fromAwsManagedPolicyName ( "AmazonSSMManagedInstanceCore" ) ,
92
+ iam . ManagedPolicy . fromAwsManagedPolicyName ( "CloudWatchAgentServerPolicy" )
89
93
90
- const instanceRole = iam . Role . fromRoleArn ( this , "iam-role" , importedInstanceRoleArn ) ;
94
+ ]
95
+ } ) ;
96
+
97
+ instanceRole . addToPolicy ( new iam . PolicyStatement ( {
98
+ resources : [ "*" ] ,
99
+ actions : [ "cloudformation:SignalResource" ]
100
+ } ) ) ;
101
+
102
+
103
+ new cdk . CfnOutput ( this , "Instance Role ARN" , {
104
+ value : instanceRole . roleArn ,
105
+ exportName : "EdgeNodeInstanceRoleArn"
106
+ } ) ;
91
107
92
108
// Making sure our instance will be able to read the assets
93
109
bucket . grantRead ( instanceRole ) ;
@@ -97,7 +113,7 @@ export class AlloraStack extends cdk.Stack {
97
113
const singleNodeProps : SingleNodeConstructCustomProps = {
98
114
instanceName : `${ resourceNamePrefix } Instance` ,
99
115
instanceType : new ec2 . InstanceType ( instanceType ) ,
100
- dataVolumes : dataVolume ? [ dataVolume ] : [ ] , // Define your data volumes here
116
+ dataVolumes : [ dataVolume ] , // Define your data volumes here
101
117
machineImage : ec2 . MachineImage . genericLinux ( { [ region ] : amiId } ) ,
102
118
role : instanceRole ,
103
119
vpc : vpc ,
@@ -129,7 +145,7 @@ export class AlloraStack extends cdk.Stack {
129
145
const eip = new ec2 . CfnEIP ( this , `${ resourceNamePrefix } EIP` ) ;
130
146
new ec2 . CfnEIPAssociation ( this , `${ resourceNamePrefix } EIPAssociation` , {
131
147
eip : eip . ref ,
132
- instanceId : instance . instanceId ,
148
+ instanceId : singleNode . instanceId ,
133
149
} ) ;
134
150
135
151
nag . NagSuppressions . addResourceSuppressions (
0 commit comments