Skip to content

Commit

Permalink
Merge pull request #25 from nRFCloud/joco/fix-resolving-constructs
Browse files Browse the repository at this point in the history
Fix for resolving provider field
  • Loading branch information
jfrconley authored Jul 13, 2024
2 parents 557df88 + 1f55ae1 commit de80613
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-flowers-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nrfcloud/cdktf-aws-adaptor": patch
---

fix for trying to resolve provider field
15 changes: 15 additions & 0 deletions src/__tests__/cdk-adaptor-stack.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AppsyncGraphqlApi } from "@cdktf/provider-aws/lib/appsync-graphql-api/index.js";
import { CloudcontrolapiResource } from "@cdktf/provider-aws/lib/cloudcontrolapi-resource/index.js";
import { IamRole } from "@cdktf/provider-aws/lib/iam-role/index.js";
import { AwsProvider } from "@cdktf/provider-aws/lib/provider/index.js";
import { S3BucketPolicy } from "@cdktf/provider-aws/lib/s3-bucket-policy/index.js";
import { S3Bucket } from "@cdktf/provider-aws/lib/s3-bucket/index.js";
import { S3Object } from "@cdktf/provider-aws/lib/s3-object/index.js";
Expand Down Expand Up @@ -247,6 +248,20 @@ describe("Stack synthesis", () => {
bucket: "cdktf-test-bucket",
});
});

it("Should synthesize explicit provider specification", () => {
const testApp = Testing.app();
class TestStackWithCustomProvider extends AwsTerraformAdaptorStack {
public readonly testProvider = new AwsProvider(this, "test-provider");
public readonly bucket = new S3Bucket(this, "bucket", {
bucket: "cool-bucket",
provider: this.testProvider,
});
}
const testStack = new TestStackWithCustomProvider(testApp, "test-stack-3", {});
testStack.prepareStack();
expect(Testing.synth.bind(Testing, testStack)).not.toThrow();
});
});

describe("Dependency order preservation", () => {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/core/cdk-adaptor-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TerraformElement,
TerraformLocal,
TerraformOutput,
TerraformProvider,
TerraformResource,
TerraformStack,
TerraformVariable,
Expand Down Expand Up @@ -347,10 +348,10 @@ export abstract class AwsTerraformAdaptorStack extends TerraformStack {
) continue;

if (
typeof value === "function"
|| isConstruct(value)
|| value == null
typeof value === "function" || isConstruct(value) || value == null
|| value.crossStackIdentifier != null
|| TerraformResource.isTerraformResource(value)
|| TerraformProvider.isTerraformProvider(value)
) continue;
if (value["internalValue"] == null) {
const resolvedValue = this.host.resolve(value);
Expand Down

0 comments on commit de80613

Please sign in to comment.