Skip to content

Commit 3e63643

Browse files
committed
More Python, Go, C#, Java
1 parent 42bcbc1 commit 3e63643

File tree

1 file changed

+126
-2
lines changed

1 file changed

+126
-2
lines changed

content/docs/iac/extending-pulumi/use-terraform-module.md

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,11 @@ In the above code, the imported Terraform module works the same as any other Pul
741741
742742
Some modules require Terraform providers to be configured with specific settings. You can configure these providers from within Pulumi:
743743
744-
{{% chooser language "typescript" %}}
744+
{{% chooser language "typescript,python,go,csharp,java" %}}
745745
746746
{{% choosable language typescript %}}
747747
748-
**Example:** index.ts - Configuring the imported Terraform bucket module*
748+
**Example:** `index.ts` - Configuring the imported Terraform bucket module
749749

750750
```typescript
751751
import * as bucket from "@pulumi/bucket";
@@ -765,6 +765,130 @@ const testBucket = new bucket.Module("test-bucket", {
765765
766766
{{% /choosable %}}
767767
768+
{{% choosable language python %}}
769+
770+
**Example:** `__main__.py` - Configuring the imported Terraform bucket module
771+
772+
```python
773+
import pulumi
774+
import pulumi_bucket as bucket
775+
776+
# Configure the AWS provider for the module
777+
provider = bucket.Provider("bucket-provider", aws={
778+
"region": "us-west-2"
779+
})
780+
781+
# Use the provider with the module
782+
test_bucket = bucket.Module("test-bucket",
783+
bucket=f"${prefix}-test-bucket"
784+
opts=pulumi.ResourceOptions(provider=provider)
785+
)
786+
```
787+
788+
{{% /choosable %}}
789+
790+
{{% choosable language go %}}
791+
792+
**Example:** `main.go` - Configuring the imported Terraform bucket module
793+
794+
```go
795+
package main
796+
797+
import (
798+
bucket "github.com/pulumi/pulumi-terraform-module/sdks/go/bucket/v3/bucket"
799+
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
800+
)
801+
802+
803+
func run(ctx *pulumi.Context) error {
804+
// Configure the AWS provider for the module
805+
prov, err := bucket.NewProvider(ctx, "provider", &bucket.ProviderArgs{
806+
Aws: pulumi.ToMap(map[string]any{
807+
"region": "us-west-2",
808+
}),
809+
})
810+
if err != nil {
811+
return err
812+
}
813+
814+
// Use the provider with the module
815+
bucketInstance, err := bucket.NewModule(ctx, "test-bucket", &bucket.ModuleArgs{
816+
Bucket: pulumi.Sprintf("test-vpc-%s", prefix),
817+
}, pulumi.Provider(prov))
818+
if err != nil {
819+
return err
820+
}
821+
}
822+
823+
func main() {
824+
pulumi.Run(run)
825+
}
826+
```
827+
828+
{{% /choosable %}}
829+
830+
{{% choosable language csharp %}}
831+
832+
**Example:** `Program.cs` - Configuring the imported Terraform bucket module
833+
834+
```csharp
835+
using Pulumi;
836+
using Bucket = Pulumi.Bucket;
837+
838+
return await Deployment.RunAsync(() =>
839+
{
840+
// Configure the AWS provider for the module
841+
var provider = new Bucket.Provider("test-provider", new Bucket.ProviderArgs
842+
{
843+
Aws = {{"region", "us-west-2"}}
844+
});
845+
846+
// Use the provider with the module
847+
var bucket = new Bucket.Module("test-bucket", new Bucket.Args
848+
{
849+
Bucket = $"{prefix}-test-bucket"
850+
}, new CustomResourceOptions
851+
{
852+
Provider = provider
853+
});
854+
```
855+
856+
{{% /choosable %}}
857+
858+
{{% choosable language java %}}
859+
860+
**Example:** `App.java` - Configuring the imported Terraform bucket module
861+
862+
```java
863+
import com.pulumi.Context;
864+
import com.pulumi.Pulumi;
865+
import com.pulumi.resources.CustomResourceOptions;
866+
867+
public class App {
868+
public static void stack(Context ctx) {
869+
870+
// Configure the AWS provider for the module
871+
final var provider = new com.pulumi.bucket.Provider("test-provider",
872+
com.pulumi.bucket.ProviderArgs.builder()
873+
.aws(Collections.singletonMap("region", "us-west-2"))
874+
.build());
875+
876+
// Use the provider with the module
877+
final var bucket = new com.pulumi.bucket.Module("test-bucket",
878+
com.pulumi.bucket.ModuleArgs.builder()
879+
.bucket(prefix+"-test-bucket")
880+
.build(),
881+
CustomResourceOptions.builder().provider(provider).build());
882+
}
883+
884+
public static void main(String[] args) {
885+
Pulumi.run(App::stack);
886+
}
887+
}
888+
```
889+
890+
{{% /choosable %}}
891+
768892
{{% /chooser %}}
769893

770894
Provider configuration is module-specific, so refer to the module's documentation for available configuration options.

0 commit comments

Comments
 (0)