diff --git a/api-docs/README.md b/api-docs/README.md index 255a082b..7816a53f 100644 --- a/api-docs/README.md +++ b/api-docs/README.md @@ -121,7 +121,7 @@ Create and register an AWS CDK stack deployed with Pulumi. ###### Defined in -[stack.ts:261](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L261) +[stack.ts:264](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L264) #### Methods @@ -151,7 +151,7 @@ A Pulumi Output value. ###### Defined in -[stack.ts:274](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L274) +[stack.ts:277](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L277) ## Interfaces @@ -241,7 +241,7 @@ Options for creating a Pulumi CDK Stack | Property | Type | Description | Defined in | | ------ | ------ | ------ | ------ | -| `props?` | `StackProps` | The CDK Stack props | [stack.ts:227](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L227) | +| `props?` | `StackProps` | The CDK Stack props | [stack.ts:230](https://github.com/pulumi/pulumi-cdk/blob/main/src/stack.ts#L230) | ## Type Aliases diff --git a/examples/examples_nodejs_test.go b/examples/examples_nodejs_test.go index 091c00c2..a465f0d2 100644 --- a/examples/examples_nodejs_test.go +++ b/examples/examples_nodejs_test.go @@ -15,13 +15,20 @@ package examples import ( + "bytes" + "context" "fmt" + "math/rand" "path/filepath" "testing" "time" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/route53" + "github.com/aws/aws-sdk-go-v2/service/sts" "github.com/gorilla/websocket" "github.com/pulumi/pulumi/pkg/v3/testing/integration" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -118,6 +125,90 @@ func TestLookups(t *testing.T) { integration.ProgramTest(t, &test) } +func TestLookupsEnabled(t *testing.T) { + ctx := context.Background() + config, err := config.LoadDefaultConfig(ctx) + assert.NoError(t, err) + client := sts.NewFromConfig(config) + route53Client := route53.NewFromConfig(config) + result, err := client.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{}) + assert.NoError(t, err) + accountId := *result.Account + + // create a zone that we can lookup in the test + randomSuffix := rand.Intn(10000) + zoneName := fmt.Sprintf("cdkexample-%d.com", randomSuffix) + res, err := route53Client.CreateHostedZone(ctx, &route53.CreateHostedZoneInput{ + Name: &zoneName, + CallerReference: &zoneName, + }) + require.NoError(t, err) + zoneId := *res.HostedZone.Id + + var output bytes.Buffer + + test := getJSBaseOptions(t). + With(integration.ProgramTestOptions{ + Dir: filepath.Join(getCwd(t), "lookups-enabled"), + Env: []string{"PULUMI_CDK_EXPERIMENTAL_LOOKUPS=true"}, + Stderr: &output, + Quick: false, + SkipPreview: false, + Config: map[string]string{ + "zoneName": zoneName, + "accountId": accountId, + }, + }) + + tester := integration.ProgramTestManualLifeCycle(t, &test) + + defer func() { + tester.TestLifeCycleDestroy() + tester.TestCleanUp() + route53Client.DeleteHostedZone(ctx, &route53.DeleteHostedZoneInput{ + Id: &zoneId, + }) + }() + err = tester.TestLifeCyclePrepare() + assert.NoError(t, err) + err = tester.TestLifeCycleInitialize() + assert.NoError(t, err) + tester.RunPulumiCommand("preview") + assert.Contains(t, output.String(), "Duplicate resource URN") + + err = tester.TestPreviewUpdateAndEdits() + assert.NoErrorf(t, err, "Failed to preview update and edits: \n output: %s", output.String()) +} + +func TestLookupsEnabledFailWithoutPreview(t *testing.T) { + ctx := context.Background() + config, err := config.LoadDefaultConfig(ctx) + assert.NoError(t, err) + client := sts.NewFromConfig(config) + result, err := client.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{}) + assert.NoError(t, err) + accountId := *result.Account + + var output bytes.Buffer + + test := getJSBaseOptions(t). + With(integration.ProgramTestOptions{ + Dir: filepath.Join(getCwd(t), "lookups-enabled"), + Env: []string{"PULUMI_CDK_EXPERIMENTAL_LOOKUPS=true"}, + Stderr: &output, + SkipPreview: true, + ExpectFailure: true, + Config: map[string]string{ + "zoneName": "coolcompany.io", + "accountId": accountId, + "pulumiResources": "false", + }, + }) + + integration.ProgramTest(t, &test) + assert.Contains(t, output.String(), "Context lookups have been disabled") +} + func TestEventBridgeSNS(t *testing.T) { test := getJSBaseOptions(t). With(integration.ProgramTestOptions{ diff --git a/examples/lookups-enabled/Pulumi.yaml b/examples/lookups-enabled/Pulumi.yaml new file mode 100644 index 00000000..cc542902 --- /dev/null +++ b/examples/lookups-enabled/Pulumi.yaml @@ -0,0 +1,3 @@ +name: pulumi-lookups-enabled +runtime: nodejs +description: A minimal TypeScript Pulumi program diff --git a/examples/lookups-enabled/index.ts b/examples/lookups-enabled/index.ts new file mode 100644 index 00000000..d4fffeac --- /dev/null +++ b/examples/lookups-enabled/index.ts @@ -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']; diff --git a/examples/lookups-enabled/package.json b/examples/lookups-enabled/package.json new file mode 100644 index 00000000..902cb0ea --- /dev/null +++ b/examples/lookups-enabled/package.json @@ -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" + } +} diff --git a/examples/lookups-enabled/tsconfig.json b/examples/lookups-enabled/tsconfig.json new file mode 100644 index 00000000..2666e28e --- /dev/null +++ b/examples/lookups-enabled/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/go.mod b/go.mod index c2ca990a..36dedbd7 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,11 @@ module github.com/pulumi/pulumi-cdk go 1.22.5 require ( - github.com/aws/aws-sdk-go v1.50.36 github.com/aws/aws-sdk-go-v2/config v1.27.11 + github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2 github.com/aws/aws-sdk-go-v2/service/s3 v1.67.0 - github.com/aws/smithy-go v1.22.0 + github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 + github.com/aws/smithy-go v1.22.1 github.com/gorilla/websocket v1.5.3 github.com/pulumi/pulumi/pkg/v3 v3.137.0 github.com/stretchr/testify v1.9.0 @@ -35,22 +36,22 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2 v1.32.4 // indirect + github.com/aws/aws-sdk-go v1.50.36 // indirect + github.com/aws/aws-sdk-go-v2 v1.32.5 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4 // indirect github.com/aws/aws-sdk-go-v2/service/kms v1.30.1 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/cenkalti/backoff/v3 v3.2.2 // indirect diff --git a/go.sum b/go.sum index e3550346..13a8b37e 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/aws-sdk-go v1.50.36 h1:PjWXHwZPuTLMR1NIb8nEjLucZBMzmf84TLoLbD8BZqk= github.com/aws/aws-sdk-go v1.50.36/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= -github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= +github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo= +github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 h1:pT3hpW0cOHRJx8Y0DfJUEQuqPild8jRGmSFmBgvydr0= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6/go.mod h1:j/I2++U0xX+cr44QjHay4Cvxj6FUbnxrgmqN3H1jTZA= github.com/aws/aws-sdk-go-v2/config v1.27.11 h1:f47rANd2LQEYHda2ddSCKYId18/8BhSRM4BULGmfgNA= @@ -65,36 +65,38 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 h1:FVJ0r5XTHSmIHJV6KuDmdYh github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1/go.mod h1:zusuAeqezXzAB24LGuzuekqMAEgWkVYukBec3kr3jUg= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15 h1:7Zwtt/lP3KNRkeZre7soMELMGNoBrutx8nobg1jKWmo= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15/go.mod h1:436h2adoHb57yd+8W+gYPrrA9U/R/SuAuOO42Ushzhw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 h1:A2w6m6Tmr+BNXjDsr7M90zkWjsu4JXHwrzPg235STs4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23/go.mod h1:35EVp9wyeANdujZruvHiQUAo9E3vbhnIO1mTCAxMlY0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 h1:pgYW9FCabt2M25MoHYCfMrVY2ghiiBKYWUVXfwZs+sU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23/go.mod h1:c48kLgzO19wAu3CPkDWC28JbaJ+hfQlsdl7I2+oqIbk= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24/go.mod h1:dCn9HbJ8+K31i8IQ8EWmWj0EiIk0+vKiHNMxTTYveAg= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23 h1:1SZBDiRzzs3sNhOMVApyWPduWYGAX0imGy06XiBnCAM= github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23/go.mod h1:i9TkxgbZmHVh2S0La6CAXtnyFhlCX/pJ0JsOvBAS6Mk= github.com/aws/aws-sdk-go-v2/service/iam v1.31.4 h1:eVm30ZIDv//r6Aogat9I88b5YX1xASSLcEDqHYRPVl0= github.com/aws/aws-sdk-go-v2/service/iam v1.31.4/go.mod h1:aXWImQV0uTW35LM0A/T4wEg6R1/ReXUu4SM6/lUHYK0= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4 h1:aaPpoG15S2qHkWm4KlEyF01zovK1nW4BBbyXuHNSE90= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4/go.mod h1:eD9gS2EARTKgGr/W5xwgY/ik9z/zqpW+m/xOQbVxrMk= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 h1:tHxQi/XHPK0ctd/wdOw0t7Xrc2OxcRCnVzv8lwWPu0c= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4/go.mod h1:4GQbF1vJzG60poZqWatZlhP31y8PGCCVTvIGPdaaYJ0= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4 h1:E5ZAVOmI2apR8ADb72Q63KqwwwdW1XcMeXIlrZ1Psjg= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4/go.mod h1:wezzqVUOVVdk+2Z/JzQT4NxAU0NbhRe5W8pIE72jsWI= github.com/aws/aws-sdk-go-v2/service/kms v1.30.1 h1:SBn4I0fJXF9FYOVRSVMWuhvEKoAHDikjGpS3wlmw5DE= github.com/aws/aws-sdk-go-v2/service/kms v1.30.1/go.mod h1:2snWQJQUKsbN66vAawJuOGX7dr37pfOq9hb0tZDGIqQ= +github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2 h1:wmt05tPp/CaRZpPV5B4SaJ5TwkHKom07/BzHoLdkY1o= +github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2/go.mod h1:d+K9HESMpGb1EU9/UmmpInbGIUcAkwmcY6ZO/A3zZsw= github.com/aws/aws-sdk-go-v2/service/s3 v1.67.0 h1:SwaJ0w0MOp0pBTIKTamLVeTKD+iOWyNJRdJ2KCQRg6Q= github.com/aws/aws-sdk-go-v2/service/s3 v1.67.0/go.mod h1:TMhLIyRIyoGVlaEMAt+ITMbwskSTpcGsCPDq91/ihY0= github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 h1:vN8hEbpRnL7+Hopy9dzmRle1xmDc7o8tmY0klsr175w= github.com/aws/aws-sdk-go-v2/service/sso v1.20.5/go.mod h1:qGzynb/msuZIE8I75DVRCUXw3o3ZyBmUvMwQ2t/BrGM= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 h1:Jux+gDDyi1Lruk+KHF91tK2KCuY61kzoCpvtvJJBtOE= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4/go.mod h1:mUYPBhaF2lGiukDEjJX2BLRRKTmoUSitGDUgM4tRxak= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 h1:cwIxeBttqPN3qkaAjcEcsh8NYr8n2HZPkcKgPAi1phU= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.6/go.mod h1:FZf1/nKNEkHdGGJP/cI2MoIMquumuRK6ol3QQJNDxmw= -github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= -github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLbc2iVROyaNEwBHbU= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg= +github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= +github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= diff --git a/src/stack.ts b/src/stack.ts index 9a067283..c9c21c6e 100644 --- a/src/stack.ts +++ b/src/stack.ts @@ -148,16 +148,19 @@ export class App const cli = AwsCdkCli.fromCloudAssemblyDirectoryProducer(this); this.appProps = props.args?.props; this.appOptions = props.args; + const lookupsEnabled = process.env.PULUMI_CDK_EXPERIMENTAL_LOOKUPS === 'true'; + const lookups = lookupsEnabled && pulumi.runtime.isDryRun(); try { // TODO: support lookups https://github.com/pulumi/pulumi-cdk/issues/184 - await cli.synth({ quiet: true, lookups: false }); + await cli.synth({ quiet: true, lookups }); } catch (e: any) { if (typeof e.message === 'string' && e.message.includes('Context lookups have been disabled')) { const message = e.message as string; const messageParts = message.split('Context lookups have been disabled. '); const missingParts = messageParts[1].split('Missing context keys: '); throw new Error( - 'Context lookups have been disabled. Make sure all necessary context is already in "cdk.context.json". \n' + + 'Context lookups have been disabled. Make sure all necessary context is already in "cdk.context.json". ' + + 'Or set "PULUMI_CDK_EXPERIMENTAL_LOOKUPS" to true. \n' + 'Missing context keys: ' + missingParts[1], );