Skip to content

Commit eb29542

Browse files
committed
Merge branch 'garrjh-c9reboot' into 'main'
Reboot c9 instance after attaching instance profile See merge request observability-bd-projects/one-observability-demo!154
2 parents 33dfa90 + e6661b2 commit eb29542

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

PetAdoptions/cdk/pet_stack/lib/common/container-image-builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class ContainerImageBuilder extends Construct {
3232
repositoryName: props.repositoryName,
3333
imageScanOnPush: true,
3434
removalPolicy: cdk.RemovalPolicy.DESTROY,
35-
autoDeleteImages: true,
35+
emptyOnDelete: true,
3636
});
3737
const image = new ecrassets.DockerImageAsset(this, props.repositoryName + 'DockerImageAsset', {
3838
directory: props.dockerImageAssetDirectory
@@ -45,4 +45,4 @@ export class ContainerImageBuilder extends Construct {
4545
this.repositoryUri = repository.repositoryUri;
4646
this.imageUri = `${repository.repositoryUri}:latest`;
4747
}
48-
}
48+
}

PetAdoptions/cdk/pet_stack/package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111
"test": "jest",
1212
"cdk": "cdk"
1313
},
14-
"devDependencies": {
15-
"@aws-cdk/assert": "^2.68.0",
16-
"@types/jest": "^29.5.4",
17-
"@types/node": "^20.5.7",
18-
"aws-cdk": "^2.97.0",
19-
"constructs": "^10.2.69",
20-
"ts-jest": "^29.1.1",
21-
"ts-node": "^10.9.1",
22-
"ts-replace-all": "1.0.0",
23-
"typescript": "^5.2.2"
24-
},
2514
"dependencies": {
26-
"@aws-cdk/aws-lambda-python-alpha": "^2.97.0-alpha.0",
27-
"@types/js-yaml": "4.0.5",
28-
"aws-cdk-lib": "^2.97.0",
29-
"cdk-ecr-deployment": "^2.5.30",
30-
"jest": "^29.6.4",
15+
"@aws-cdk/aws-lambda-python-alpha": "^2.131.0-alpha.0",
16+
"@types/js-yaml": "^4.0.9",
17+
"aws-cdk-lib": "^2.146.0",
18+
"cdk-ecr-deployment": "^3.0.67",
19+
"jest": "^29.7.0",
3120
"js-yaml": "^4.1.0",
3221
"source-map-support": "^0.5.21"
22+
},
23+
"devDependencies": {
24+
"@types/jest": "^29.5.12",
25+
"@types/node": "^20.14.2",
26+
"aws-cdk": "^2.146.0",
27+
"cdk-nag": "^2.28.144",
28+
"constructs": "^10.3.0",
29+
"ts-jest": "^29.1.5",
30+
"ts-node": "^10.9.2",
31+
"ts-replace-all": "^1.0.0",
32+
"typescript": "^5.4.5"
3333
}
34-
}
34+
}

buildspec.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
version: 0.2
2+
env:
3+
variables:
4+
# https://github.com/cdklabs/cdk-ecr-deployment/issues/478#issuecomment-1938020710
5+
NO_PREBUILT_LAMBDA: "1"
26
phases:
37
install:
48
commands:
@@ -15,4 +19,4 @@ phases:
1519
- cdk deploy Services --context admin_role=${EE_TEAM_ROLE_ARN} --context is_event_engine="true" --require-approval=never --verbose -O ./out/out.json
1620
- cdk deploy Applications --require-approval=never --verbose -O ./out/out.json
1721
artifacts:
18-
files: './PetAdoptions/cdk/pet_stack/out/out.json'
22+
files: "./PetAdoptions/cdk/pet_stack/out/out.json"

cloud9-cfn.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ Resources:
465465
- ec2:AssociateIamInstanceProfile
466466
- ec2:ModifyInstanceAttribute
467467
- ec2:ReplaceIamInstanceProfileAssociation
468+
- ec2:RebootInstances
468469
Resource: !Sub "arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*"
469470
- Effect: Allow
470471
Action:
@@ -595,7 +596,7 @@ Resources:
595596
# attach instance profile
596597
response = ec2.associate_iam_instance_profile(IamInstanceProfile=iam_instance_profile, InstanceId=instance['InstanceId'])
597598
logger.info('response - associate_iam_instance_profile: {}'.format(response))
598-
#r_ec2 = boto3.resource('ec2')
599+
ec2.reboot_instances(InstanceIds=[instance['InstanceId']], DryRun=False)
599600
600601
responseData = {'Success': 'Started bootstrapping for instance: '+instance['InstanceId']}
601602
cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData, 'CustomResourcePhysicalID')

0 commit comments

Comments
 (0)