in cdk/lib/aws-iot-sec-tunnel-stack.ts [22:74]
constructor(app: cdk.App, id: string) {
super(app, id, ENV_PROPS);
let deviceVpc = new ec2.Vpc(this, 'iotSecureTunneling',{
maxAzs: 2,
});
const githubRepoUrl = new cdk.CfnParameter(this, 'githubRepoUrl', {
type: "String",
description: "The location of the Github repo used for the demo",
default: "https://github.com/aws-samples/iot-secure-tunneling-demo.git"
});
const instanceRole = new iam.Role(this,'ssminstancerole',
{
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonEC2RoleforSSM'),
iam.ManagedPolicy.fromAwsManagedPolicyName('AWSCloudFormationReadOnlyAccess'),
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ReadOnlyAccess')
]
});
const secureTunnelInstanceProfile = new iam.CfnInstanceProfile( this,'secureTunnelProfile',{
roles: [instanceRole.roleName]
})
const ubuntuAmi = ec2.MachineImage.lookup({
name: 'ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200112',
}).getImage(this).imageId;
configJson.things.forEach(thingConfig=> {
/* create thing through construct */
new thing.IotThing(this, thingConfig.name, {
machineImageId: ubuntuAmi,
vpc: deviceVpc,
keyName: KEY_NAME,
thingName: thingConfig.name,
instanceProfile: secureTunnelInstanceProfile,
githubRepoUrl: githubRepoUrl.valueAsString,
resources: thingConfig.resources
});
});
let s3Bucket = new s3.Bucket(this, 'aws-secure-tunneling-demo');
new cdk.CfnOutput(this, 's3BucketName', {
value: s3Bucket.bucketName,
description: 'S3 bucket that will hold some objects needed to run this demo.'
});
}