Skip to content

Commit 4abc06e

Browse files
Add terraformConfig provider method by default (#3007)
This PR adds a provider method called `terraformConfig` via function token to all bridged provider's schema. The implementation of functionality is then by token recognition in the Call() methods for the provider: 1. in tfbridge/provider.go for SDK v2 2. in pf/tfbridge/provider.go for Plugin Framework. The core of the change involves returning a Pulumi propertyMap with Terraform-formatted keys, so that the return of `myprovider.terraformConfig()` can be passed directly to a terraform module provider's required provider as a valid config object. Example Usage for module providers - note that this requires configuring an explicit provider. ```typescript const awsProvider = new aws.Provider("awsprovider", { region: "us-west-2", endpoints: [ {accessanalyzer: "alpha"}, {account: "myaccount"} ], ignoreTags: { keyPrefixes: ["apple", "pear", "banana"] } }) const bucketProvider = new bucket.Provider("bucketprovider", { "aws": awsProvider.terraformConfig().result }) ``` Addresses pulumi/pulumi-terraform-module#17.
1 parent 664e7ea commit 4abc06e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1536
-38
lines changed

dynamic/provider_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,13 @@ func TestSchemaGeneration(t *testing.T) { //nolint:paralleltest
417417
skipWindows(t)
418418

419419
t.Run("unparameterized", func(t *testing.T) {
420+
t.Skipf("Skipping due to https://github.com/pulumi/pulumi/issues/19274")
420421
helper.Integration(t)
421422
ctx := context.Background()
422423

423-
schema, err := grpcTestServer(ctx, t).
424-
GetSchema(ctx, &pulumirpc.GetSchemaRequest{})
424+
server := grpcTestServer(ctx, t)
425+
426+
schema, err := server.GetSchema(ctx, &pulumirpc.GetSchemaRequest{})
425427

426428
require.NoError(t, err)
427429
var fmtSchema bytes.Buffer

dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden

+32
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@
607607
"type": "string",
608608
"description": "B2 endpoint - production or custom URL (B2_ENDPOINT env)\n"
609609
}
610+
},
611+
"methods": {
612+
"terraformConfig": "pulumi:providers:b2/terraformConfig"
610613
}
611614
},
612615
"resources": {
@@ -1460,6 +1463,35 @@
14601463
"id"
14611464
]
14621465
}
1466+
},
1467+
"pulumi:providers:b2/terraformConfig": {
1468+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
1469+
"inputs": {
1470+
"properties": {
1471+
"__self__": {
1472+
"type": "ref",
1473+
"$ref": "#/resources/pulumi:providers:b2"
1474+
}
1475+
},
1476+
"type": "pulumi:providers:b2/terraformConfig",
1477+
"required": [
1478+
"__self__"
1479+
]
1480+
},
1481+
"outputs": {
1482+
"properties": {
1483+
"result": {
1484+
"additionalProperties": {
1485+
"$ref": "pulumi.json#/Any"
1486+
},
1487+
"type": "object"
1488+
}
1489+
},
1490+
"required": [
1491+
"result"
1492+
],
1493+
"type": "object"
1494+
}
14631495
}
14641496
},
14651497
"parameterization": {

dynamic/testdata/TestSchemaGeneration/BunnyWay/bunnynet-0.5.1.golden

+32
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@
282282
"type": "string",
283283
"description": "Optional. The Stream API URL. Defaults to `https://video.bunnycdn.com`.\n"
284284
}
285+
},
286+
"methods": {
287+
"terraformConfig": "pulumi:providers:bunnynet/terraformConfig"
285288
}
286289
},
287290
"resources": {
@@ -3885,6 +3888,35 @@
38853888
"id"
38863889
]
38873890
}
3891+
},
3892+
"pulumi:providers:bunnynet/terraformConfig": {
3893+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
3894+
"inputs": {
3895+
"properties": {
3896+
"__self__": {
3897+
"type": "ref",
3898+
"$ref": "#/resources/pulumi:providers:bunnynet"
3899+
}
3900+
},
3901+
"type": "pulumi:providers:bunnynet/terraformConfig",
3902+
"required": [
3903+
"__self__"
3904+
]
3905+
},
3906+
"outputs": {
3907+
"properties": {
3908+
"result": {
3909+
"additionalProperties": {
3910+
"$ref": "pulumi.json#/Any"
3911+
},
3912+
"type": "object"
3913+
}
3914+
},
3915+
"required": [
3916+
"result"
3917+
],
3918+
"type": "object"
3919+
}
38883920
}
38893921
},
38903922
"parameterization": {

dynamic/testdata/TestSchemaGeneration/databricks/databricks-1.50.0.golden

+32
Original file line numberDiff line numberDiff line change
@@ -15899,6 +15899,9 @@
1589915899
"warehouseId": {
1590015900
"type": "string"
1590115901
}
15902+
},
15903+
"methods": {
15904+
"terraformConfig": "pulumi:providers:databricks/terraformConfig"
1590215905
}
1590315906
},
1590415907
"resources": {
@@ -30168,6 +30171,35 @@
3016830171
"zones"
3016930172
]
3017030173
}
30174+
},
30175+
"pulumi:providers:databricks/terraformConfig": {
30176+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
30177+
"inputs": {
30178+
"properties": {
30179+
"__self__": {
30180+
"type": "ref",
30181+
"$ref": "#/resources/pulumi:providers:databricks"
30182+
}
30183+
},
30184+
"type": "pulumi:providers:databricks/terraformConfig",
30185+
"required": [
30186+
"__self__"
30187+
]
30188+
},
30189+
"outputs": {
30190+
"properties": {
30191+
"result": {
30192+
"additionalProperties": {
30193+
"$ref": "pulumi.json#/Any"
30194+
},
30195+
"type": "object"
30196+
}
30197+
},
30198+
"required": [
30199+
"result"
30200+
],
30201+
"type": "object"
30202+
}
3017130203
}
3017230204
},
3017330205
"parameterization": {

dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden

+35-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
},
4747
"config": {},
4848
"provider": {
49-
"description": "The provider type for the random package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n"
49+
"description": "The provider type for the random package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n",
50+
"methods": {
51+
"terraformConfig": "pulumi:providers:random/terraformConfig"
52+
}
5053
},
5154
"resources": {
5255
"random:index/id:Id": {
@@ -827,6 +830,37 @@
827830
}
828831
}
829832
},
833+
"functions": {
834+
"pulumi:providers:random/terraformConfig": {
835+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
836+
"inputs": {
837+
"properties": {
838+
"__self__": {
839+
"type": "ref",
840+
"$ref": "#/resources/pulumi:providers:random"
841+
}
842+
},
843+
"type": "pulumi:providers:random/terraformConfig",
844+
"required": [
845+
"__self__"
846+
]
847+
},
848+
"outputs": {
849+
"properties": {
850+
"result": {
851+
"additionalProperties": {
852+
"$ref": "pulumi.json#/Any"
853+
},
854+
"type": "object"
855+
}
856+
},
857+
"required": [
858+
"result"
859+
],
860+
"type": "object"
861+
}
862+
}
863+
},
830864
"parameterization": {
831865
"baseProvider": {
832866
"name": "terraform-provider",

dynamic/testdata/TestSchemaGenerationFullDocs/fortinetdev/fortimanager-1.13.0.golden

+34
Original file line numberDiff line numberDiff line change
@@ -39531,6 +39531,9 @@
3953139531
"username": {
3953239532
"type": "string"
3953339533
}
39534+
},
39535+
"methods": {
39536+
"terraformConfig": "pulumi:providers:fortimanager/terraformConfig"
3953439537
}
3953539538
},
3953639539
"resources": {
@@ -291441,6 +291444,37 @@
291441291444
}
291442291445
}
291443291446
},
291447+
"functions": {
291448+
"pulumi:providers:fortimanager/terraformConfig": {
291449+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
291450+
"inputs": {
291451+
"properties": {
291452+
"__self__": {
291453+
"type": "ref",
291454+
"$ref": "#/resources/pulumi:providers:fortimanager"
291455+
}
291456+
},
291457+
"type": "pulumi:providers:fortimanager/terraformConfig",
291458+
"required": [
291459+
"__self__"
291460+
]
291461+
},
291462+
"outputs": {
291463+
"properties": {
291464+
"result": {
291465+
"additionalProperties": {
291466+
"$ref": "pulumi.json#/Any"
291467+
},
291468+
"type": "object"
291469+
}
291470+
},
291471+
"required": [
291472+
"result"
291473+
],
291474+
"type": "object"
291475+
}
291476+
}
291477+
},
291444291478
"parameterization": {
291445291479
"baseProvider": {
291446291480
"name": "terraform-provider",

dynamic/testdata/TestSchemaGenerationFullDocs/hashicorp/random-3.6.3.golden

+35-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
},
4747
"config": {},
4848
"provider": {
49-
"description": "The provider type for the random package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n"
49+
"description": "The provider type for the random package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n",
50+
"methods": {
51+
"terraformConfig": "pulumi:providers:random/terraformConfig"
52+
}
5053
},
5154
"resources": {
5255
"random:index/bytes:Bytes": {
@@ -929,6 +932,37 @@
929932
}
930933
}
931934
},
935+
"functions": {
936+
"pulumi:providers:random/terraformConfig": {
937+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
938+
"inputs": {
939+
"properties": {
940+
"__self__": {
941+
"type": "ref",
942+
"$ref": "#/resources/pulumi:providers:random"
943+
}
944+
},
945+
"type": "pulumi:providers:random/terraformConfig",
946+
"required": [
947+
"__self__"
948+
]
949+
},
950+
"outputs": {
951+
"properties": {
952+
"result": {
953+
"additionalProperties": {
954+
"$ref": "pulumi.json#/Any"
955+
},
956+
"type": "object"
957+
}
958+
},
959+
"required": [
960+
"result"
961+
],
962+
"type": "object"
963+
}
964+
}
965+
},
932966
"parameterization": {
933967
"baseProvider": {
934968
"name": "terraform-provider",

internal/testprovider_sdkv2/cmd/pulumi-resource-tpsdkv2/schema.json

+31
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,37 @@
145145
"strConfigProp": {
146146
"type": "string"
147147
}
148+
},
149+
"methods": {
150+
"terraformConfig": "pulumi:providers:tpsdkv2/terraformConfig"
151+
}
152+
},
153+
"functions": {
154+
"pulumi:providers:tpsdkv2/terraformConfig": {
155+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
156+
"inputs": {
157+
"properties": {
158+
"__self__": {
159+
"type": "ref",
160+
"$ref": "#/resources/pulumi:providers:tpsdkv2"
161+
}
162+
},
163+
"type": "pulumi:providers:tpsdkv2/terraformConfig",
164+
"required": [
165+
"__self__"
166+
]
167+
},
168+
"outputs": {
169+
"properties": {
170+
"result": {
171+
"type": "string"
172+
}
173+
},
174+
"required": [
175+
"result"
176+
],
177+
"type": "object"
178+
}
148179
}
149180
}
150181
}

pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-muxedrandom/schema.json

+35-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
},
2828
"config": {},
2929
"provider": {
30-
"description": "The provider type for the muxedrandom package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n"
30+
"description": "The provider type for the muxedrandom package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n",
31+
"methods": {
32+
"terraformConfig": "pulumi:providers:muxedrandom/terraformConfig"
33+
}
3134
},
3235
"resources": {
3336
"muxedrandom:index/myNumber:MyNumber": {
@@ -1010,5 +1013,36 @@
10101013
"type": "object"
10111014
}
10121015
}
1016+
},
1017+
"functions": {
1018+
"pulumi:providers:muxedrandom/terraformConfig": {
1019+
"description": "This function returns a Terraform config object with terraform-namecased keys,to be used with the Terraform Module Provider.",
1020+
"inputs": {
1021+
"properties": {
1022+
"__self__": {
1023+
"type": "ref",
1024+
"$ref": "#/resources/pulumi:providers:muxedrandom"
1025+
}
1026+
},
1027+
"type": "pulumi:providers:muxedrandom/terraformConfig",
1028+
"required": [
1029+
"__self__"
1030+
]
1031+
},
1032+
"outputs": {
1033+
"properties": {
1034+
"result": {
1035+
"additionalProperties": {
1036+
"$ref": "pulumi.json#/Any"
1037+
},
1038+
"type": "object"
1039+
}
1040+
},
1041+
"required": [
1042+
"result"
1043+
],
1044+
"type": "object"
1045+
}
1046+
}
10131047
}
10141048
}

0 commit comments

Comments
 (0)