-
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.
Add experimental flag for enabling CDK lookups (#235)
This adds a new environment variable flag `PULUMI_CDK_EXPERIMENTAL_LOOKUPS` that enables CDK lookups during preview operations. I am working on adding the documentation in a follow up PR #234 re #184
- Loading branch information
Showing
9 changed files
with
239 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: pulumi-lookups-enabled | ||
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,81 @@ | ||
import * as aws from '@pulumi/aws'; | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import { | ||
aws_elasticloadbalancingv2, | ||
aws_elasticloadbalancingv2_targets, | ||
aws_route53, | ||
aws_route53_targets, | ||
CfnOutput, | ||
} from 'aws-cdk-lib'; | ||
|
||
const config = new pulumi.Config(); | ||
const zoneName = config.require('zoneName'); | ||
const accountId = config.require('accountId'); | ||
const region = aws.config.requireRegion(); | ||
|
||
export class Ec2CdkStack extends pulumicdk.Stack { | ||
constructor(app: pulumicdk.App, id: string) { | ||
super(app, id, { | ||
props: { | ||
env: { region, account: accountId }, | ||
}, | ||
}); | ||
|
||
// 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', | ||
owners: ['amazon'], | ||
}); | ||
|
||
const instance = new ec2.Instance(this, 'Instance', { | ||
vpc, | ||
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T4G, ec2.InstanceSize.MICRO), | ||
machineImage, | ||
}); | ||
|
||
const lb = new aws_elasticloadbalancingv2.ApplicationLoadBalancer(this, 'lb', { | ||
vpc, | ||
}); | ||
|
||
const listener = lb.addListener('http', { | ||
protocol: aws_elasticloadbalancingv2.ApplicationProtocol.HTTP, | ||
}); | ||
|
||
listener.addTargets('instance', { | ||
protocol: aws_elasticloadbalancingv2.ApplicationProtocol.HTTP, | ||
targets: [new aws_elasticloadbalancingv2_targets.InstanceTarget(instance)], | ||
}); | ||
|
||
const hostedZone = aws_route53.HostedZone.fromLookup(this, 'hosted-zone', { | ||
domainName: zoneName, | ||
}); | ||
|
||
new aws_route53.AaaaRecord(this, 'record', { | ||
zone: hostedZone, | ||
target: aws_route53.RecordTarget.fromAlias(new aws_route53_targets.LoadBalancerTarget(lb)), | ||
}); | ||
|
||
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['imageId']; | ||
export const instanceId = app.outputs['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,13 @@ | ||
{ | ||
"name": "pulumi-aws-cdk", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^6.0.0", | ||
"@pulumi/aws-native": "^1.9.0", | ||
"@pulumi/cdk": "^0.5.0", | ||
"aws-cdk-lib": "2.156.0", | ||
"constructs": "10.3.0" | ||
} | ||
} |
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