-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cdk-cli-lib to synthesize CDK application
- Loading branch information
Showing
10 changed files
with
278 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: pulumi-lookups | ||
runtime: nodejs | ||
description: A minimal TypeScript Pulumi program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as aws from '@pulumi/aws-native'; | ||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import { CfnOutput } from 'aws-cdk-lib'; | ||
|
||
export class Ec2CdkStack extends pulumicdk.Stack { | ||
constructor(app: pulumicdk.App, id: string) { | ||
super(app, id, { | ||
props: { | ||
env: { region: process.env.AWS_REGION, account: process.env.AWS_ACCOUNT }, | ||
}, | ||
}); | ||
|
||
// Create new VPC with 2 Subnets | ||
const vpc = new ec2.Vpc(this, 'VPC', { | ||
natGateways: 0, | ||
subnetConfiguration: [ | ||
{ | ||
cidrMask: 24, | ||
name: 'asterisk', | ||
subnetType: ec2.SubnetType.PUBLIC, | ||
}, | ||
], | ||
}); | ||
const machineImage = new ec2.LookupMachineImage({ | ||
name: 'al2023-ami-2023.*.*.*.*-arm64', | ||
}); | ||
|
||
const instance = new ec2.Instance(this, 'Instance', { | ||
vpc, | ||
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T4G, ec2.InstanceSize.MICRO), | ||
machineImage, | ||
}); | ||
|
||
const param = new aws.ssm.Parameter('param', { | ||
value: this.asOutput(instance.instanceId), | ||
type: 'String', | ||
}); | ||
|
||
new CfnOutput(this, 'instanceId', { value: instance.instanceId }); | ||
new CfnOutput(this, 'imageId', { value: machineImage.getImage(this).imageId }); | ||
} | ||
} | ||
|
||
const app = new pulumicdk.App('app', (scope: pulumicdk.App) => { | ||
new Ec2CdkStack(scope, 'teststack'); | ||
}); | ||
|
||
export const imageId = app.outputs.then((output) => output['imageId']); | ||
export const instanceId = app.outputs.then((output) => output['instanceId']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "pulumi-aws-cdk", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^4.6.0", | ||
"@pulumi/aws-native": "^1.0.2", | ||
"@pulumi/cdk": "^0.5.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"aws-cdk-lib": "2.149.0", | ||
"constructs": "^10.0.111" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.