From b3cb210717681e3e946684f7570944402878d9bf Mon Sep 17 00:00:00 2001 From: aq17 Date: Mon, 17 Oct 2022 17:37:57 +0000 Subject: [PATCH] (pulumi-bot) Created local 'pkg/codegen/testing/test/testdata/transpiled_examples' from remote 'pkg/tests/transpiled_examples' --- .../aws-eks/dotnet/MyStack.cs | 31 +++++ .../transpiled_examples/aws-eks/go/main.go | 31 +++++ .../transpiled_examples/aws-eks/program.pp | 21 +++ .../aws-eks/python/__main__.py | 14 ++ .../aws-static-website/program.pp | 38 ++++++ .../aws-static-website/python/__main__.py | 33 +++++ .../awsx-fargate/dotnet/MyStack.cs | 41 ++++++ .../awsx-fargate/go/main.go | 45 +++++++ .../awsx-fargate/nodejs/index.ts | 21 +++ .../awsx-fargate/program.pp | 28 ++++ .../awsx-fargate/python/__main__.py | 20 +++ .../azure-app-service/nodejs/index.ts | 100 ++++++++++++++ .../azure-app-service/program.pp | 123 ++++++++++++++++++ .../azure-app-service/python/__main__.py | 91 +++++++++++++ .../azure-container-apps/program.pp | 102 +++++++++++++++ .../azure-static-website/program.pp | 55 ++++++++ .../cue-eks/dotnet/MyStack.cs | 24 ++++ .../transpiled_examples/cue-eks/go/main.go | 30 +++++ .../transpiled_examples/cue-eks/program.pp | 15 +++ .../cue-eks/python/__main__.py | 13 ++ .../cue-random/dotnet/MyStack.cs | 19 +++ .../transpiled_examples/cue-random/go/main.go | 23 ++++ .../cue-random/nodejs/index.ts | 9 ++ .../transpiled_examples/cue-random/program.pp | 11 ++ .../cue-random/python/__main__.py | 8 ++ .../cue-static-web-app/dotnet/MyStack.cs | 68 ++++++++++ .../cue-static-web-app/go/main.go | 85 ++++++++++++ .../cue-static-web-app/nodejs/index.ts | 47 +++++++ .../cue-static-web-app/program.pp | 63 +++++++++ .../cue-static-web-app/python/__main__.py | 41 ++++++ .../getting-started/dotnet/MyStack.cs | 27 ++++ .../getting-started/go/main.go | 34 +++++ .../getting-started/nodejs/index.ts | 13 ++ .../getting-started/program.pp | 16 +++ .../getting-started/python/__main__.py | 12 ++ .../test/testdata/transpiled_examples/go.mod | 0 .../kubernetes/dotnet/MyStack.cs | 121 +++++++++++++++++ .../transpiled_examples/kubernetes/go/main.go | 119 +++++++++++++++++ .../kubernetes/nodejs/index.ts | 75 +++++++++++ .../transpiled_examples/kubernetes/program.pp | 82 ++++++++++++ .../kubernetes/python/__main__.py | 74 +++++++++++ .../pulumi-variable/program.pp | 14 ++ .../pulumi-variable/python/__main__.py | 6 + .../transpiled_examples/random/go/main.go | 23 ++++ .../transpiled_examples/random/program.pp | 11 ++ .../random/python/__main__.py | 8 ++ .../transpiled_examples/readme/go/main.go | 27 ++++ .../readme/nodejs/index.ts | 9 ++ .../transpiled_examples/readme/program.pp | 17 +++ .../readme/python/__main__.py | 8 ++ .../stackreference-consumer/program.pp | 6 + .../python/__main__.py | 3 + .../stackreference-producer/nodejs/index.ts | 3 + .../stackreference-producer/program.pp | 4 + .../python/__main__.py | 3 + .../webserver-json/nodejs/index.ts | 31 +++++ .../webserver-json/program.pp | 47 +++++++ .../webserver/nodejs/index.ts | 34 +++++ .../transpiled_examples/webserver/program.pp | 58 +++++++++ 59 files changed, 2135 insertions(+) create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/azure-container-apps/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/azure-static-website/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/go.mod create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/dotnet/MyStack.cs create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/random/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/random/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/random/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/readme/go/main.go create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/readme/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/readme/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/readme/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/python/__main__.py create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/program.pp create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/webserver/nodejs/index.ts create mode 100644 pkg/codegen/testing/test/testdata/transpiled_examples/webserver/program.pp diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/dotnet/MyStack.cs new file mode 100644 index 000000000000..5ced3f2448ad --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/dotnet/MyStack.cs @@ -0,0 +1,31 @@ +using Pulumi; +using Aws = Pulumi.Aws; +using Eks = Pulumi.Eks; + +class MyStack : Stack +{ + public MyStack() + { + var vpcId = Output.Create(Aws.Ec2.GetVpc.InvokeAsync(new Aws.Ec2.GetVpcArgs + { + Default = true, + })).Apply(invoke => invoke.Id); + var subnetIds = Output.Create(Aws.Ec2.GetSubnetIds.InvokeAsync(new Aws.Ec2.GetSubnetIdsArgs + { + VpcId = vpcId, + })).Apply(invoke => invoke.Ids); + var cluster = new Eks.Cluster("cluster", new Eks.ClusterArgs + { + VpcId = vpcId, + SubnetIds = subnetIds, + InstanceType = "t2.medium", + DesiredCapacity = 2, + MinSize = 1, + MaxSize = 2, + }); + this.Kubeconfig = cluster.Kubeconfig; + } + + [Output("kubeconfig")] + public Output Kubeconfig { get; set; } +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/go/main.go new file mode 100644 index 000000000000..deb3935724ab --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/go/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2" + "github.com/pulumi/pulumi-eks/sdk/go/eks" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + vpcId := ec2.LookupVpc(ctx, map[string]interface{}{ + "default": true, + }, nil).Id + subnetIds := ec2.GetSubnetIds(ctx, map[string]interface{}{ + "vpcId": vpcId, + }, nil).Ids + cluster, err := eks.NewCluster(ctx, "cluster", &eks.ClusterArgs{ + VpcId: pulumi.String(vpcId), + SubnetIds: interface{}(subnetIds), + InstanceType: pulumi.String("t2.medium"), + DesiredCapacity: pulumi.Int(2), + MinSize: pulumi.Int(1), + MaxSize: pulumi.Int(2), + }) + if err != nil { + return err + } + ctx.Export("kubeconfig", cluster.Kubeconfig) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/program.pp new file mode 100644 index 000000000000..84ca69daf568 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/program.pp @@ -0,0 +1,21 @@ +vpcId = invoke("aws:ec2/getVpc:getVpc", { + default = true +}).id +subnetIds = invoke("aws:ec2/getSubnetIds:getSubnetIds", { + vpcId = vpcId +}).ids + +resource cluster "eks:index:Cluster" { + __logicalName = "cluster" + vpcId = vpcId + subnetIds = subnetIds + instanceType = "t2.medium" + desiredCapacity = 2 + minSize = 1 + maxSize = 2 +} + +output kubeconfig { + __logicalName = "kubeconfig" + value = cluster.kubeconfig +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/python/__main__.py new file mode 100644 index 000000000000..afdc46f3fdf4 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-eks/python/__main__.py @@ -0,0 +1,14 @@ +import pulumi +import pulumi_aws as aws +import pulumi_eks as eks + +vpc_id = aws.ec2.get_vpc().id +subnet_ids = aws.ec2.get_subnet_ids().ids +cluster = eks.Cluster("cluster", + vpc_id=vpc_id, + subnet_ids=subnet_ids, + instance_type="t2.medium", + desired_capacity=2, + min_size=1, + max_size=2) +pulumi.export("kubeconfig", cluster.kubeconfig) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/program.pp new file mode 100644 index 000000000000..01f1954cbece --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/program.pp @@ -0,0 +1,38 @@ +resource siteBucket "aws-native:s3:Bucket" { + __logicalName = "site-bucket" + websiteConfiguration = { + indexDocument = "index.html" + } +} + +resource indexHtml "aws:s3/bucketObject:BucketObject" { + __logicalName = "index.html" + bucket = siteBucket.id + source = fileAsset("./www/index.html") + acl = "public-read" + contentType = "text/html" +} + +resource faviconPng "aws:s3/bucketObject:BucketObject" { + __logicalName = "favicon.png" + bucket = siteBucket.id + source = fileAsset("./www/favicon.png") + acl = "public-read" + contentType = "image/png" +} + +resource bucketPolicy "aws:s3/bucketPolicy:BucketPolicy" { + __logicalName = "bucketPolicy" + bucket = siteBucket.id + policy = "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\"s3:GetObject\"],\n \"Resource\": [\"${siteBucket.arn}/*\"]\n }\n ]\n}\n" +} + +output bucketName { + __logicalName = "bucketName" + value = siteBucket.bucketName +} + +output websiteUrl { + __logicalName = "websiteUrl" + value = siteBucket.websiteURL +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/python/__main__.py new file mode 100644 index 000000000000..7665f54cfdd3 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/aws-static-website/python/__main__.py @@ -0,0 +1,33 @@ +import pulumi +import pulumi_aws as aws +import pulumi_aws_native as aws_native + +site_bucket = aws_native.s3.Bucket("site-bucket", website_configuration=aws_native.s3.BucketWebsiteConfigurationArgs( + index_document="index.html", +)) +index_html = aws.s3.BucketObject("index.html", + bucket=site_bucket.id, + source=pulumi.FileAsset("./www/index.html"), + acl="public-read", + content_type="text/html") +favicon_png = aws.s3.BucketObject("favicon.png", + bucket=site_bucket.id, + source=pulumi.FileAsset("./www/favicon.png"), + acl="public-read", + content_type="image/png") +bucket_policy = aws.s3.BucketPolicy("bucketPolicy", + bucket=site_bucket.id, + policy=site_bucket.arn.apply(lambda arn: f"""{{ + "Version": "2012-10-17", + "Statement": [ + {{ + "Effect": "Allow", + "Principal": "*", + "Action": ["s3:GetObject"], + "Resource": ["{arn}/*"] + }} + ] +}} +""")) +pulumi.export("bucketName", site_bucket.bucket_name) +pulumi.export("websiteUrl", site_bucket.website_url) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/dotnet/MyStack.cs new file mode 100644 index 000000000000..7b1a01c3eb12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/dotnet/MyStack.cs @@ -0,0 +1,41 @@ +using Pulumi; +using Aws = Pulumi.Aws; +using Awsx = Pulumi.Awsx; + +class MyStack : Stack +{ + public MyStack() + { + var cluster = new Aws.Ecs.Cluster("cluster", new Aws.Ecs.ClusterArgs + { + }); + var lb = new Awsx.Lb.ApplicationLoadBalancer("lb", new Awsx.Lb.ApplicationLoadBalancerArgs + { + }); + var nginx = new Awsx.Ecs.FargateService("nginx", new Awsx.Ecs.FargateServiceArgs + { + Cluster = cluster.Arn, + TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs + { + Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs + { + Image = "nginx:latest", + Cpu = 512, + Memory = 128, + PortMappings = + { + new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs + { + ContainerPort = 80, + TargetGroup = lb.DefaultTargetGroup, + }, + }, + }, + }, + }); + this.Url = lb.LoadBalancer.Apply(loadBalancer => loadBalancer.DnsName); + } + + [Output("url")] + public Output Url { get; set; } +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/go/main.go new file mode 100644 index 000000000000..6ed056dffbd0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/go/main.go @@ -0,0 +1,45 @@ +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs" + "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb" + "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecs" + "github.com/pulumi/pulumi-awsx/sdk/go/awsx/lb" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + cluster, err := ecs.NewCluster(ctx, "cluster", nil) + if err != nil { + return err + } + lb, err := lb.NewApplicationLoadBalancer(ctx, "lb", nil) + if err != nil { + return err + } + _, err = ecs.NewFargateService(ctx, "nginx", &ecs.FargateServiceArgs{ + Cluster: cluster.Arn, + TaskDefinitionArgs: &ecs.FargateServiceTaskDefinitionArgs{ + Container: &ecs.TaskDefinitionContainerDefinitionArgs{ + Image: pulumi.String("nginx:latest"), + Cpu: pulumi.Int(512), + Memory: pulumi.Int(128), + PortMappings: []ecs.TaskDefinitionPortMappingArgs{ + &ecs.TaskDefinitionPortMappingArgs{ + ContainerPort: pulumi.Int(80), + TargetGroup: lb.DefaultTargetGroup, + }, + }, + }, + }, + }) + if err != nil { + return err + } + ctx.Export("url", lb.LoadBalancer.ApplyT(func(loadBalancer *lb.LoadBalancer) (string, error) { + return loadBalancer.DnsName, nil + }).(pulumi.StringOutput)) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/nodejs/index.ts new file mode 100644 index 000000000000..9745e4eda68a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/nodejs/index.ts @@ -0,0 +1,21 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; +import * as awsx from "@pulumi/awsx"; + +const cluster = new aws.ecs.Cluster("cluster", {}); +const lb = new awsx.lb.ApplicationLoadBalancer("lb", {}); +const nginx = new awsx.ecs.FargateService("nginx", { + cluster: cluster.arn, + taskDefinitionArgs: { + container: { + image: "nginx:latest", + cpu: 512, + memory: 128, + portMappings: [{ + containerPort: 80, + targetGroup: lb.defaultTargetGroup, + }], + }, + }, +}); +export const url = lb.loadBalancer.dnsName; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/program.pp new file mode 100644 index 000000000000..cf98c6f9ade1 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/program.pp @@ -0,0 +1,28 @@ +resource cluster "aws:ecs/cluster:Cluster" { + __logicalName = "cluster" +} + +resource lb "awsx:lb:ApplicationLoadBalancer" { + __logicalName = "lb" +} + +resource nginx "awsx:ecs:FargateService" { + __logicalName = "nginx" + cluster = cluster.arn + taskDefinitionArgs = { + container = { + image = "nginx:latest", + cpu = 512, + memory = 128, + portMappings = [{ + containerPort = 80, + targetGroup = lb.defaultTargetGroup + }] + } + } +} + +output url { + __logicalName = "url" + value = lb.loadBalancer.dnsName +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/python/__main__.py new file mode 100644 index 000000000000..69df42bfe33d --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/awsx-fargate/python/__main__.py @@ -0,0 +1,20 @@ +import pulumi +import pulumi_aws as aws +import pulumi_awsx as awsx + +cluster = aws.ecs.Cluster("cluster") +lb = awsx.lb.ApplicationLoadBalancer("lb") +nginx = awsx.ecs.FargateService("nginx", + cluster=cluster.arn, + task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( + container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( + image="nginx:latest", + cpu=512, + memory=128, + port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs( + container_port=80, + target_group=lb.default_target_group, + )], + ), + )) +pulumi.export("url", lb.load_balancer.dns_name) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/nodejs/index.ts new file mode 100644 index 000000000000..f7328e723ea9 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/nodejs/index.ts @@ -0,0 +1,100 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as azure_native from "@pulumi/azure-native"; +import * as random from "@pulumi/random"; + +const config = new pulumi.Config(); +const sqlAdmin = config.get("sqlAdmin") || "pulumi"; +const appservicegroup = new azure_native.resources.ResourceGroup("appservicegroup", {}); +const sa = new azure_native.storage.StorageAccount("sa", { + resourceGroupName: appservicegroup.name, + kind: "StorageV2", + sku: { + name: "Standard_LRS", + }, +}); +const container = new azure_native.storage.BlobContainer("container", { + resourceGroupName: appservicegroup.name, + accountName: sa.name, + publicAccess: azure_native.storage.PublicAccess.None, +}); +const blobAccessToken = pulumi.secret(pulumi.all([sa.name, appservicegroup.name, sa.name, container.name]).apply(([saName, appservicegroupName, saName1, containerName]) => azure_native.storage.listStorageAccountServiceSASOutput({ + accountName: saName, + protocols: azure_native.storage.HttpProtocol.Https, + sharedAccessStartTime: "2022-01-01", + sharedAccessExpiryTime: "2030-01-01", + resource: "c", + resourceGroupName: appservicegroupName, + permissions: "r", + canonicalizedResource: `/blob/${saName1}/${containerName}`, + contentType: "application/json", + cacheControl: "max-age=5", + contentDisposition: "inline", + contentEncoding: "deflate", +})).apply(invoke => invoke.serviceSasToken)); +const appserviceplan = new azure_native.web.AppServicePlan("appserviceplan", { + resourceGroupName: appservicegroup.name, + kind: "App", + sku: { + name: "B1", + tier: "Basic", + }, +}); +const blob = new azure_native.storage.Blob("blob", { + resourceGroupName: appservicegroup.name, + accountName: sa.name, + containerName: container.name, + type: azure_native.storage.BlobType.Block, + source: new pulumi.asset.FileArchive("./www"), +}); +const appInsights = new azure_native.insights.Component("appInsights", { + resourceGroupName: appservicegroup.name, + applicationType: "web", + kind: "web", +}); +const sqlPassword = new random.RandomPassword("sqlPassword", { + length: 16, + special: true, +}); +const sqlServer = new azure_native.sql.Server("sqlServer", { + resourceGroupName: appservicegroup.name, + administratorLogin: sqlAdmin, + administratorLoginPassword: sqlPassword.result, + version: "12.0", +}); +const db = new azure_native.sql.Database("db", { + resourceGroupName: appservicegroup.name, + serverName: sqlServer.name, + sku: { + name: "S0", + }, +}); +const app = new azure_native.web.WebApp("app", { + resourceGroupName: appservicegroup.name, + serverFarmId: appserviceplan.id, + siteConfig: { + appSettings: [ + { + name: "WEBSITE_RUN_FROM_PACKAGE", + value: pulumi.all([sa.name, container.name, blob.name, blobAccessToken]).apply(([saName, containerName, blobName, blobAccessToken]) => `https://${saName}.blob.core.windows.net/${containerName}/${blobName}?${blobAccessToken}`), + }, + { + name: "APPINSIGHTS_INSTRUMENTATIONKEY", + value: appInsights.instrumentationKey, + }, + { + name: "APPLICATIONINSIGHTS_CONNECTION_STRING", + value: pulumi.interpolate`InstrumentationKey=${appInsights.instrumentationKey}`, + }, + { + name: "ApplicationInsightsAgent_EXTENSION_VERSION", + value: "~2", + }, + ], + connectionStrings: [{ + name: "db", + type: azure_native.web.ConnectionStringType.SQLAzure, + connectionString: pulumi.interpolate`Server= tcp:${sqlServer.name}.database.windows.net;initial catalog=${db.name};userID=${sqlAdmin};password=${sqlPassword.result};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;`, + }], + }, +}); +export const endpoint = app.defaultHostName; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/program.pp new file mode 100644 index 000000000000..f01122887941 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/program.pp @@ -0,0 +1,123 @@ +config sqlAdmin string { + default = "pulumi" +} + +blobAccessToken = secret(invoke("azure-native:storage:listStorageAccountServiceSAS", { + accountName = sa.name, + protocols = "https", + sharedAccessStartTime = "2022-01-01", + sharedAccessExpiryTime = "2030-01-01", + resource = "c", + resourceGroupName = appservicegroup.name, + permissions = "r", + canonicalizedResource = "/blob/${sa.name}/${container.name}", + contentType = "application/json", + cacheControl = "max-age=5", + contentDisposition = "inline", + contentEncoding = "deflate" +}).serviceSasToken) + +resource appservicegroup "azure-native:resources:ResourceGroup" { + __logicalName = "appservicegroup" +} + +resource sa "azure-native:storage:StorageAccount" { + __logicalName = "sa" + resourceGroupName = appservicegroup.name + kind = "StorageV2" + sku = { + name = "Standard_LRS" + } +} + +resource appserviceplan "azure-native:web:AppServicePlan" { + __logicalName = "appserviceplan" + resourceGroupName = appservicegroup.name + kind = "App" + sku = { + name = "B1", + tier = "Basic" + } +} + +resource container "azure-native:storage:BlobContainer" { + __logicalName = "container" + resourceGroupName = appservicegroup.name + accountName = sa.name + publicAccess = "None" +} + +resource blob "azure-native:storage:Blob" { + __logicalName = "blob" + resourceGroupName = appservicegroup.name + accountName = sa.name + containerName = container.name + type = "Block" + source = fileArchive("./www") +} + +resource appInsights "azure-native:insights:Component" { + __logicalName = "appInsights" + resourceGroupName = appservicegroup.name + applicationType = "web" + kind = "web" +} + +resource sqlPassword "random:index/randomPassword:RandomPassword" { + __logicalName = "sqlPassword" + length = 16 + special = true +} + +resource sqlServer "azure-native:sql:Server" { + __logicalName = "sqlServer" + resourceGroupName = appservicegroup.name + administratorLogin = sqlAdmin + administratorLoginPassword = sqlPassword.result + version = "12.0" +} + +resource db "azure-native:sql:Database" { + __logicalName = "db" + resourceGroupName = appservicegroup.name + serverName = sqlServer.name + sku = { + name = "S0" + } +} + +resource app "azure-native:web:WebApp" { + __logicalName = "app" + resourceGroupName = appservicegroup.name + serverFarmId = appserviceplan.id + siteConfig = { + appSettings = [ + { + name = "WEBSITE_RUN_FROM_PACKAGE", + value = "https://${sa.name}.blob.core.windows.net/${container.name}/${blob.name}?${blobAccessToken}" + }, + { + name = "APPINSIGHTS_INSTRUMENTATIONKEY", + value = appInsights.instrumentationKey + }, + { + name = "APPLICATIONINSIGHTS_CONNECTION_STRING", + value = "InstrumentationKey=${appInsights.instrumentationKey}" + }, + { + name = "ApplicationInsightsAgent_EXTENSION_VERSION", + value = "~2" + } + ], + connectionStrings = [{ + name = "db", + type = "SQLAzure", + connectionString = "Server= tcp:${sqlServer.name}.database.windows.net;initial catalog=${db.name};userID=${sqlAdmin};password=${sqlPassword.result};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;" + }] + } +} + +output endpoint { + __logicalName = "endpoint" + value = app.defaultHostName +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/python/__main__.py new file mode 100644 index 000000000000..f38d0add807f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-app-service/python/__main__.py @@ -0,0 +1,91 @@ +import pulumi +import pulumi_azure_native as azure_native +import pulumi_random as random + +config = pulumi.Config() +sql_admin = config.get("sqlAdmin") +if sql_admin is None: + sql_admin = "pulumi" +appservicegroup = azure_native.resources.ResourceGroup("appservicegroup") +sa = azure_native.storage.StorageAccount("sa", + resource_group_name=appservicegroup.name, + kind="StorageV2", + sku=azure_native.storage.SkuArgs( + name="Standard_LRS", + )) +container = azure_native.storage.BlobContainer("container", + resource_group_name=appservicegroup.name, + account_name=sa.name, + public_access=azure_native.storage.PublicAccess.NONE) +blob_access_token = pulumi.secret(pulumi.Output.all(sa.name, appservicegroup.name, sa.name, container.name).apply(lambda saName, appservicegroupName, saName1, containerName: azure_native.storage.list_storage_account_service_sas_output(account_name=sa_name, + protocols=azure_native.storage.HttpProtocol.HTTPS, + shared_access_start_time="2022-01-01", + shared_access_expiry_time="2030-01-01", + resource="c", + resource_group_name=appservicegroup_name, + permissions="r", + canonicalized_resource=f"/blob/{sa_name1}/{container_name}", + content_type="application/json", + cache_control="max-age=5", + content_disposition="inline", + content_encoding="deflate")).apply(lambda invoke: invoke.service_sas_token)) +appserviceplan = azure_native.web.AppServicePlan("appserviceplan", + resource_group_name=appservicegroup.name, + kind="App", + sku=azure_native.web.SkuDescriptionArgs( + name="B1", + tier="Basic", + )) +blob = azure_native.storage.Blob("blob", + resource_group_name=appservicegroup.name, + account_name=sa.name, + container_name=container.name, + type=azure_native.storage.BlobType.BLOCK, + source=pulumi.FileArchive("./www")) +app_insights = azure_native.insights.Component("appInsights", + resource_group_name=appservicegroup.name, + application_type="web", + kind="web") +sql_password = random.RandomPassword("sqlPassword", + length=16, + special=True) +sql_server = azure_native.sql.Server("sqlServer", + resource_group_name=appservicegroup.name, + administrator_login=sql_admin, + administrator_login_password=sql_password.result, + version="12.0") +db = azure_native.sql.Database("db", + resource_group_name=appservicegroup.name, + server_name=sql_server.name, + sku=azure_native.sql.SkuArgs( + name="S0", + )) +app = azure_native.web.WebApp("app", + resource_group_name=appservicegroup.name, + server_farm_id=appserviceplan.id, + site_config=azure_native.web.SiteConfigArgs( + app_settings=[ + azure_native.web.NameValuePairArgs( + name="WEBSITE_RUN_FROM_PACKAGE", + value=pulumi.Output.all(sa.name, container.name, blob.name, blob_access_token).apply(lambda saName, containerName, blobName, blob_access_token: f"https://{sa_name}.blob.core.windows.net/{container_name}/{blob_name}?{blob_access_token}"), + ), + azure_native.web.NameValuePairArgs( + name="APPINSIGHTS_INSTRUMENTATIONKEY", + value=app_insights.instrumentation_key, + ), + azure_native.web.NameValuePairArgs( + name="APPLICATIONINSIGHTS_CONNECTION_STRING", + value=app_insights.instrumentation_key.apply(lambda instrumentation_key: f"InstrumentationKey={instrumentation_key}"), + ), + azure_native.web.NameValuePairArgs( + name="ApplicationInsightsAgent_EXTENSION_VERSION", + value="~2", + ), + ], + connection_strings=[azure_native.web.ConnStringInfoArgs( + name="db", + type=azure_native.web.ConnectionStringType.SQL_AZURE, + connection_string=pulumi.Output.all(sql_server.name, db.name, sql_password.result).apply(lambda sqlServerName, dbName, result: f"Server= tcp:{sql_server_name}.database.windows.net;initial catalog={db_name};userID={sql_admin};password={result};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;"), + )], + )) +pulumi.export("endpoint", app.default_host_name) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/azure-container-apps/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-container-apps/program.pp new file mode 100644 index 000000000000..2d814260e636 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-container-apps/program.pp @@ -0,0 +1,102 @@ +config sqlAdmin string { + default = "pulumi" +} + +sharedKey = secret(invoke("azure-native:operationalinsights:getSharedKeys", { + resourceGroupName = resourceGroup.name, + workspaceName = workspace.name +}).primarySharedKey) +adminRegistryCreds = invoke("azure-native:containerregistry:listRegistryCredentials", { + resourceGroupName = resourceGroup.name, + registryName = registry.name +}) +adminUsername = adminRegistryCreds.username +adminPasswords = secret(adminRegistryCreds.passwords) + +resource resourceGroup "azure-native:resources:ResourceGroup" { + __logicalName = "resourceGroup" +} + +resource workspace "azure-native:operationalinsights:Workspace" { + __logicalName = "workspace" + resourceGroupName = resourceGroup.name + sku = { + name = "PerGB2018" + } + retentionInDays = 30 +} + +resource kubeEnv "azure-native:web:KubeEnvironment" { + __logicalName = "kubeEnv" + resourceGroupName = resourceGroup.name + environmentType = "Managed" + appLogsConfiguration = { + destination = "log-analytics", + logAnalyticsConfiguration = { + customerId = workspace.customerId, + sharedKey = sharedKey + } + } +} + +resource registry "azure-native:containerregistry:Registry" { + __logicalName = "registry" + resourceGroupName = resourceGroup.name + sku = { + name = "Basic" + } + adminUserEnabled = true +} + +resource provider "pulumi:providers:docker" { + __logicalName = "provider" + registryAuth = [{ + address = registry.loginServer, + username = adminUsername, + password = adminPasswords[0].value + }] +} + +resource myImage "docker:index/registryImage:RegistryImage" { + __logicalName = "myImage" + name = "${registry.loginServer}/node-app:v1.0.0" + build = { + context = "${cwd()}/node-app" + } + + options { + provider = provider + } +} + +resource containerapp "azure-native:web:ContainerApp" { + __logicalName = "containerapp" + resourceGroupName = resourceGroup.name + kubeEnvironmentId = kubeEnv.id + configuration = { + ingress = { + external = true, + targetPort = 80 + }, + registries = [{ + server = registry.loginServer, + username = adminUsername, + passwordSecretRef = "pwd" + }], + secrets = [{ + name = "pwd", + value = adminPasswords[0].value + }] + } + template = { + containers = [{ + name = "myapp", + image = myImage.name + }] + } +} + +output endpoint { + __logicalName = "endpoint" + value = "https://${containerapp.configuration.ingress.fqdn}" +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/azure-static-website/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-static-website/program.pp new file mode 100644 index 000000000000..c73a579472db --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/azure-static-website/program.pp @@ -0,0 +1,55 @@ +resource staticsitegroup "azure-native:resources:ResourceGroup" { + __logicalName = "staticsitegroup" +} + +resource storageaccount "azure-native:storage:StorageAccount" { + __logicalName = "storageaccount" + resourceGroupName = staticsitegroup.name + kind = "StorageV2" + sku = { + name = "Standard_LRS" + } +} + +resource staticwebsite "azure-native:storage:StorageAccountStaticWebsite" { + __logicalName = "staticwebsite" + resourceGroupName = staticsitegroup.name + accountName = storageaccount.name + indexDocument = "index.html" + error404Document = "404.html" +} + +resource indexHtml "azure-native:storage:Blob" { + __logicalName = "index.html" + resourceGroupName = staticsitegroup.name + accountName = storageaccount.name + containerName = staticwebsite.containerName + contentType = "text/html" + type = "Block" + source = fileAsset("./www/index.html") +} + +resource faviconPng "azure-native:storage:Blob" { + __logicalName = "favicon.png" + resourceGroupName = staticsitegroup.name + accountName = storageaccount.name + containerName = staticwebsite.containerName + contentType = "image/png" + type = "Block" + source = fileAsset("./www/favicon.png") +} + +resource "404Html" "azure-native:storage:Blob" { + __logicalName = "404.html" + resourceGroupName = staticsitegroup.name + accountName = storageaccount.name + containerName = staticwebsite.containerName + contentType = "text/html" + type = "Block" + source = fileAsset("./www/404.html") +} + +output endpoint { + __logicalName = "endpoint" + value = storageaccount.primaryEndpoints.web +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/dotnet/MyStack.cs new file mode 100644 index 000000000000..5721ae4bea2c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/dotnet/MyStack.cs @@ -0,0 +1,24 @@ +using Pulumi; +using Eks = Pulumi.Eks; + +class MyStack : Stack +{ + public MyStack() + { + var rawkode = new Eks.Cluster("rawkode", new Eks.ClusterArgs + { + InstanceType = "t2.medium", + DesiredCapacity = 2, + MinSize = 1, + MaxSize = 2, + }); + var stack72 = new Eks.Cluster("stack72", new Eks.ClusterArgs + { + InstanceType = "t2.medium", + DesiredCapacity = 4, + MinSize = 1, + MaxSize = 8, + }); + } + +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/go/main.go new file mode 100644 index 000000000000..00b376c4898a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/go/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "github.com/pulumi/pulumi-eks/sdk/go/eks" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := eks.NewCluster(ctx, "rawkode", &eks.ClusterArgs{ + InstanceType: pulumi.String("t2.medium"), + DesiredCapacity: pulumi.Int(2), + MinSize: pulumi.Int(1), + MaxSize: pulumi.Int(2), + }) + if err != nil { + return err + } + _, err = eks.NewCluster(ctx, "stack72", &eks.ClusterArgs{ + InstanceType: pulumi.String("t2.medium"), + DesiredCapacity: pulumi.Int(4), + MinSize: pulumi.Int(1), + MaxSize: pulumi.Int(8), + }) + if err != nil { + return err + } + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/program.pp new file mode 100644 index 000000000000..e25b0fcdaaf2 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/program.pp @@ -0,0 +1,15 @@ +resource rawkode "eks:index:Cluster" { + __logicalName = "rawkode" + instanceType = "t2.medium" + desiredCapacity = 2 + minSize = 1 + maxSize = 2 +} + +resource stack72 "eks:index:Cluster" { + __logicalName = "stack72" + instanceType = "t2.medium" + desiredCapacity = 4 + minSize = 1 + maxSize = 8 +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/python/__main__.py new file mode 100644 index 000000000000..e3539b6ec632 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-eks/python/__main__.py @@ -0,0 +1,13 @@ +import pulumi +import pulumi_eks as eks + +rawkode = eks.Cluster("rawkode", + instance_type="t2.medium", + desired_capacity=2, + min_size=1, + max_size=2) +stack72 = eks.Cluster("stack72", + instance_type="t2.medium", + desired_capacity=4, + min_size=1, + max_size=8) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/dotnet/MyStack.cs new file mode 100644 index 000000000000..7fa81cb22671 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/dotnet/MyStack.cs @@ -0,0 +1,19 @@ +using Pulumi; +using Random = Pulumi.Random; + +class MyStack : Stack +{ + public MyStack() + { + var randomPassword = new Random.RandomPassword("randomPassword", new Random.RandomPasswordArgs + { + Length = 16, + Special = true, + OverrideSpecial = "_%@", + }); + this.Password = randomPassword.Result; + } + + [Output("password")] + public Output Password { get; set; } +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/go/main.go new file mode 100644 index 000000000000..5ffb43512d54 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/go/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + + "github.com/pulumi/pulumi-random/sdk/v4/go/random" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + randomPassword, err := random.NewRandomPassword(ctx, "randomPassword", &random.RandomPasswordArgs{ + Length: pulumi.Int(16), + Special: pulumi.Bool(true), + OverrideSpecial: pulumi.String(fmt.Sprintf("_%v@", "%")), + }) + if err != nil { + return err + } + ctx.Export("password", randomPassword.Result) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/nodejs/index.ts new file mode 100644 index 000000000000..94205feb069c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/nodejs/index.ts @@ -0,0 +1,9 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as random from "@pulumi/random"; + +const randomPassword = new random.RandomPassword("randomPassword", { + length: 16, + special: true, + overrideSpecial: `_%@`, +}); +export const password = randomPassword.result; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/program.pp new file mode 100644 index 000000000000..3bd1c5cdf81f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/program.pp @@ -0,0 +1,11 @@ +resource randomPassword "random:index/randomPassword:RandomPassword" { + __logicalName = "randomPassword" + length = 16 + special = true + overrideSpecial = "_%@" +} + +output password { + __logicalName = "password" + value = randomPassword.result +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/python/__main__.py new file mode 100644 index 000000000000..aa99a4f8581f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-random/python/__main__.py @@ -0,0 +1,8 @@ +import pulumi +import pulumi_random as random + +random_password = random.RandomPassword("randomPassword", + length=16, + special=True, + override_special="_%@") +pulumi.export("password", random_password.result) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/dotnet/MyStack.cs new file mode 100644 index 000000000000..6350c96abc9e --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/dotnet/MyStack.cs @@ -0,0 +1,68 @@ +using Pulumi; +using AzureNative = Pulumi.AzureNative; + +class MyStack : Stack +{ + public MyStack() + { + var rawkodeGroup = new AzureNative.Resources.ResourceGroup("rawkode-group", new AzureNative.Resources.ResourceGroupArgs + { + Location = "WestUs", + }); + var rawkodeStorage = new AzureNative.Storage.StorageAccount("rawkode-storage", new AzureNative.Storage.StorageAccountArgs + { + ResourceGroupName = rawkodeGroup.Name, + Kind = "StorageV2", + Sku = new AzureNative.Storage.Inputs.SkuArgs + { + Name = "Standard_LRS", + }, + }); + var rawkodeWebsite = new AzureNative.Storage.StorageAccountStaticWebsite("rawkode-website", new AzureNative.Storage.StorageAccountStaticWebsiteArgs + { + ResourceGroupName = rawkodeGroup.Name, + AccountName = rawkodeStorage.Name, + IndexDocument = "index.html", + Error404Document = "404.html", + }); + var rawkodeIndexHtml = new AzureNative.Storage.Blob("rawkode-index.html", new AzureNative.Storage.BlobArgs + { + ResourceGroupName = rawkodeGroup.Name, + AccountName = rawkodeStorage.Name, + ContainerName = rawkodeWebsite.ContainerName, + ContentType = "text/html", + Type = AzureNative.Storage.BlobType.Block, + Source = new FileAsset("./website/index.html"), + }); + var stack72Group = new AzureNative.Resources.ResourceGroup("stack72-group", new AzureNative.Resources.ResourceGroupArgs + { + Location = "WestUs", + }); + var stack72Storage = new AzureNative.Storage.StorageAccount("stack72-storage", new AzureNative.Storage.StorageAccountArgs + { + ResourceGroupName = stack72Group.Name, + Kind = "StorageV2", + Sku = new AzureNative.Storage.Inputs.SkuArgs + { + Name = "Standard_LRS", + }, + }); + var stack72Website = new AzureNative.Storage.StorageAccountStaticWebsite("stack72-website", new AzureNative.Storage.StorageAccountStaticWebsiteArgs + { + ResourceGroupName = stack72Group.Name, + AccountName = stack72Storage.Name, + IndexDocument = "index.html", + Error404Document = "404.html", + }); + var stack72IndexHtml = new AzureNative.Storage.Blob("stack72-index.html", new AzureNative.Storage.BlobArgs + { + ResourceGroupName = stack72Group.Name, + AccountName = stack72Storage.Name, + ContainerName = stack72Website.ContainerName, + ContentType = "text/html", + Type = AzureNative.Storage.BlobType.Block, + Source = new FileAsset("./website/index.html"), + }); + } + +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/go/main.go new file mode 100644 index 000000000000..4b04d8032d52 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/go/main.go @@ -0,0 +1,85 @@ +package main + +import ( + resources "github.com/pulumi/pulumi-azure-native/sdk/go/azure/resources" + storage "github.com/pulumi/pulumi-azure-native/sdk/go/azure/storage" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + rawkodeGroup, err := resources.NewResourceGroup(ctx, "rawkode-group", &resources.ResourceGroupArgs{ + Location: pulumi.String("WestUs"), + }) + if err != nil { + return err + } + rawkodeStorage, err := storage.NewStorageAccount(ctx, "rawkode-storage", &storage.StorageAccountArgs{ + ResourceGroupName: rawkodeGroup.Name, + Kind: pulumi.String("StorageV2"), + Sku: &storage.SkuArgs{ + Name: pulumi.String("Standard_LRS"), + }, + }) + if err != nil { + return err + } + rawkodeWebsite, err := storage.NewStorageAccountStaticWebsite(ctx, "rawkode-website", &storage.StorageAccountStaticWebsiteArgs{ + ResourceGroupName: rawkodeGroup.Name, + AccountName: rawkodeStorage.Name, + IndexDocument: pulumi.String("index.html"), + Error404Document: pulumi.String("404.html"), + }) + if err != nil { + return err + } + _, err = storage.NewBlob(ctx, "rawkode-index.html", &storage.BlobArgs{ + ResourceGroupName: rawkodeGroup.Name, + AccountName: rawkodeStorage.Name, + ContainerName: rawkodeWebsite.ContainerName, + ContentType: pulumi.String("text/html"), + Type: storage.BlobTypeBlock, + Source: pulumi.NewFileAsset("./website/index.html"), + }) + if err != nil { + return err + } + stack72Group, err := resources.NewResourceGroup(ctx, "stack72-group", &resources.ResourceGroupArgs{ + Location: pulumi.String("WestUs"), + }) + if err != nil { + return err + } + stack72Storage, err := storage.NewStorageAccount(ctx, "stack72-storage", &storage.StorageAccountArgs{ + ResourceGroupName: stack72Group.Name, + Kind: pulumi.String("StorageV2"), + Sku: &storage.SkuArgs{ + Name: pulumi.String("Standard_LRS"), + }, + }) + if err != nil { + return err + } + stack72Website, err := storage.NewStorageAccountStaticWebsite(ctx, "stack72-website", &storage.StorageAccountStaticWebsiteArgs{ + ResourceGroupName: stack72Group.Name, + AccountName: stack72Storage.Name, + IndexDocument: pulumi.String("index.html"), + Error404Document: pulumi.String("404.html"), + }) + if err != nil { + return err + } + _, err = storage.NewBlob(ctx, "stack72-index.html", &storage.BlobArgs{ + ResourceGroupName: stack72Group.Name, + AccountName: stack72Storage.Name, + ContainerName: stack72Website.ContainerName, + ContentType: pulumi.String("text/html"), + Type: storage.BlobTypeBlock, + Source: pulumi.NewFileAsset("./website/index.html"), + }) + if err != nil { + return err + } + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/nodejs/index.ts new file mode 100644 index 000000000000..1d327ac0c557 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/nodejs/index.ts @@ -0,0 +1,47 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as azure_native from "@pulumi/azure-native"; + +const rawkodeGroup = new azure_native.resources.ResourceGroup("rawkode-group", {location: "WestUs"}); +const rawkodeStorage = new azure_native.storage.StorageAccount("rawkode-storage", { + resourceGroupName: rawkodeGroup.name, + kind: "StorageV2", + sku: { + name: "Standard_LRS", + }, +}); +const rawkodeWebsite = new azure_native.storage.StorageAccountStaticWebsite("rawkode-website", { + resourceGroupName: rawkodeGroup.name, + accountName: rawkodeStorage.name, + indexDocument: "index.html", + error404Document: "404.html", +}); +const rawkodeIndexHtml = new azure_native.storage.Blob("rawkode-index.html", { + resourceGroupName: rawkodeGroup.name, + accountName: rawkodeStorage.name, + containerName: rawkodeWebsite.containerName, + contentType: "text/html", + type: azure_native.storage.BlobType.Block, + source: new pulumi.asset.FileAsset("./website/index.html"), +}); +const stack72Group = new azure_native.resources.ResourceGroup("stack72-group", {location: "WestUs"}); +const stack72Storage = new azure_native.storage.StorageAccount("stack72-storage", { + resourceGroupName: stack72Group.name, + kind: "StorageV2", + sku: { + name: "Standard_LRS", + }, +}); +const stack72Website = new azure_native.storage.StorageAccountStaticWebsite("stack72-website", { + resourceGroupName: stack72Group.name, + accountName: stack72Storage.name, + indexDocument: "index.html", + error404Document: "404.html", +}); +const stack72IndexHtml = new azure_native.storage.Blob("stack72-index.html", { + resourceGroupName: stack72Group.name, + accountName: stack72Storage.name, + containerName: stack72Website.containerName, + contentType: "text/html", + type: azure_native.storage.BlobType.Block, + source: new pulumi.asset.FileAsset("./website/index.html"), +}); diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/program.pp new file mode 100644 index 000000000000..738347d89d5c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/program.pp @@ -0,0 +1,63 @@ +resource rawkodeGroup "azure-native:resources:ResourceGroup" { + __logicalName = "rawkode-group" + location = "WestUs" +} + +resource rawkodeStorage "azure-native:storage:StorageAccount" { + __logicalName = "rawkode-storage" + resourceGroupName = rawkodeGroup.name + kind = "StorageV2" + sku = { + name = "Standard_LRS" + } +} + +resource rawkodeWebsite "azure-native:storage:StorageAccountStaticWebsite" { + __logicalName = "rawkode-website" + resourceGroupName = rawkodeGroup.name + accountName = rawkodeStorage.name + indexDocument = "index.html" + error404Document = "404.html" +} + +resource rawkodeIndexHtml "azure-native:storage:Blob" { + __logicalName = "rawkode-index.html" + resourceGroupName = rawkodeGroup.name + accountName = rawkodeStorage.name + containerName = rawkodeWebsite.containerName + contentType = "text/html" + type = "Block" + source = fileAsset("./website/index.html") +} + +resource stack72Group "azure-native:resources:ResourceGroup" { + __logicalName = "stack72-group" + location = "WestUs" +} + +resource stack72Storage "azure-native:storage:StorageAccount" { + __logicalName = "stack72-storage" + resourceGroupName = stack72Group.name + kind = "StorageV2" + sku = { + name = "Standard_LRS" + } +} + +resource stack72Website "azure-native:storage:StorageAccountStaticWebsite" { + __logicalName = "stack72-website" + resourceGroupName = stack72Group.name + accountName = stack72Storage.name + indexDocument = "index.html" + error404Document = "404.html" +} + +resource stack72IndexHtml "azure-native:storage:Blob" { + __logicalName = "stack72-index.html" + resourceGroupName = stack72Group.name + accountName = stack72Storage.name + containerName = stack72Website.containerName + contentType = "text/html" + type = "Block" + source = fileAsset("./website/index.html") +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/python/__main__.py new file mode 100644 index 000000000000..649ad4913065 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/cue-static-web-app/python/__main__.py @@ -0,0 +1,41 @@ +import pulumi +import pulumi_azure_native as azure_native + +rawkode_group = azure_native.resources.ResourceGroup("rawkode-group", location="WestUs") +rawkode_storage = azure_native.storage.StorageAccount("rawkode-storage", + resource_group_name=rawkode_group.name, + kind="StorageV2", + sku=azure_native.storage.SkuArgs( + name="Standard_LRS", + )) +rawkode_website = azure_native.storage.StorageAccountStaticWebsite("rawkode-website", + resource_group_name=rawkode_group.name, + account_name=rawkode_storage.name, + index_document="index.html", + error404_document="404.html") +rawkode_index_html = azure_native.storage.Blob("rawkode-index.html", + resource_group_name=rawkode_group.name, + account_name=rawkode_storage.name, + container_name=rawkode_website.container_name, + content_type="text/html", + type=azure_native.storage.BlobType.BLOCK, + source=pulumi.FileAsset("./website/index.html")) +stack72_group = azure_native.resources.ResourceGroup("stack72-group", location="WestUs") +stack72_storage = azure_native.storage.StorageAccount("stack72-storage", + resource_group_name=stack72_group.name, + kind="StorageV2", + sku=azure_native.storage.SkuArgs( + name="Standard_LRS", + )) +stack72_website = azure_native.storage.StorageAccountStaticWebsite("stack72-website", + resource_group_name=stack72_group.name, + account_name=stack72_storage.name, + index_document="index.html", + error404_document="404.html") +stack72_index_html = azure_native.storage.Blob("stack72-index.html", + resource_group_name=stack72_group.name, + account_name=stack72_storage.name, + container_name=stack72_website.container_name, + content_type="text/html", + type=azure_native.storage.BlobType.BLOCK, + source=pulumi.FileAsset("./website/index.html")) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/dotnet/MyStack.cs new file mode 100644 index 000000000000..0abfcaa6d635 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/dotnet/MyStack.cs @@ -0,0 +1,27 @@ +using Pulumi; +using Aws = Pulumi.Aws; + +class MyStack : Stack +{ + public MyStack() + { + var mybucket = new Aws.S3.Bucket("mybucket", new Aws.S3.BucketArgs + { + Website = new Aws.S3.Inputs.BucketWebsiteArgs + { + IndexDocument = "index.html", + }, + }); + var indexhtml = new Aws.S3.BucketObject("indexhtml", new Aws.S3.BucketObjectArgs + { + Bucket = mybucket.Id, + Source = new FileArchive("

Hello, world!

"), + Acl = "public-read", + ContentType = "text/html", + }); + this.BucketEndpoint = mybucket.WebsiteEndpoint.Apply(websiteEndpoint => $"http://{websiteEndpoint}"); + } + + [Output("bucketEndpoint")] + public Output BucketEndpoint { get; set; } +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/go/main.go new file mode 100644 index 000000000000..3120a59f8141 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/go/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + + "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/s3" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + mybucket, err := s3.NewBucket(ctx, "mybucket", &s3.BucketArgs{ + Website: &s3.BucketWebsiteArgs{ + IndexDocument: pulumi.String("index.html"), + }, + }) + if err != nil { + return err + } + _, err = s3.NewBucketObject(ctx, "indexhtml", &s3.BucketObjectArgs{ + Bucket: mybucket.ID(), + Source: pulumi.NewFileArchive("

Hello, world!

"), + Acl: pulumi.String("public-read"), + ContentType: pulumi.String("text/html"), + }) + if err != nil { + return err + } + ctx.Export("bucketEndpoint", mybucket.WebsiteEndpoint.ApplyT(func(websiteEndpoint string) (string, error) { + return fmt.Sprintf("%v%v", "http://", websiteEndpoint), nil + }).(pulumi.StringOutput)) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/nodejs/index.ts new file mode 100644 index 000000000000..4d0856189ffd --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/nodejs/index.ts @@ -0,0 +1,13 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; + +const mybucket = new aws.s3.Bucket("mybucket", {website: { + indexDocument: "index.html", +}}); +const indexhtml = new aws.s3.BucketObject("indexhtml", { + bucket: mybucket.id, + source: new pulumi.asset.FileArchive("

Hello, world!

"), + acl: "public-read", + contentType: "text/html", +}); +export const bucketEndpoint = pulumi.interpolate`http://${mybucket.websiteEndpoint}`; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/program.pp new file mode 100644 index 000000000000..3a0afa284e2a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/program.pp @@ -0,0 +1,16 @@ +resource mybucket "aws:s3/bucket:Bucket" { + website = { + indexDocument = "index.html" + } +} + +resource indexhtml "aws:s3/bucketObject:BucketObject" { + bucket = mybucket.id + source = stringAsset("

Hello, world!

") + acl = "public-read" + contentType = "text/html" +} + +output bucketEndpoint { + value = "http://${mybucket.websiteEndpoint}" +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/python/__main__.py new file mode 100644 index 000000000000..b77cbd29e685 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/getting-started/python/__main__.py @@ -0,0 +1,12 @@ +import pulumi +import pulumi_aws as aws + +mybucket = aws.s3.Bucket("mybucket", website=aws.s3.BucketWebsiteArgs( + index_document="index.html", +)) +indexhtml = aws.s3.BucketObject("indexhtml", + bucket=mybucket.id, + source=pulumi.FileArchive("

Hello, world!

"), + acl="public-read", + content_type="text/html") +pulumi.export("bucketEndpoint", mybucket.website_endpoint.apply(lambda website_endpoint: f"http://{website_endpoint}")) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/go.mod b/pkg/codegen/testing/test/testdata/transpiled_examples/go.mod new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/dotnet/MyStack.cs b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/dotnet/MyStack.cs new file mode 100644 index 000000000000..4c70c5f9fec7 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/dotnet/MyStack.cs @@ -0,0 +1,121 @@ +using Pulumi; +using Kubernetes = Pulumi.Kubernetes; + +class MyStack : Stack +{ + public MyStack() + { + var config = new Config(); + var hostname = config.Get("hostname") ?? "example.com"; + var nginxDemo = new Kubernetes.Core.V1.Namespace("nginx-demo", new Kubernetes.Types.Inputs.Core.V1.NamespaceArgs + { + }); + var app = new Kubernetes.Apps.V1.Deployment("app", new Kubernetes.Types.Inputs.Apps.V1.DeploymentArgs + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Namespace = nginxDemo.Metadata.Apply(metadata => metadata?.Name), + }, + Spec = new Kubernetes.Types.Inputs.Apps.V1.DeploymentSpecArgs + { + Selector = new Kubernetes.Types.Inputs.Meta.V1.LabelSelectorArgs + { + MatchLabels = + { + { "app.kubernetes.io/name", "nginx-demo" }, + }, + }, + Replicas = 1, + Template = new Kubernetes.Types.Inputs.Core.V1.PodTemplateSpecArgs + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Labels = + { + { "app.kubernetes.io/name", "nginx-demo" }, + }, + }, + Spec = new Kubernetes.Types.Inputs.Core.V1.PodSpecArgs + { + Containers = + { + new Kubernetes.Types.Inputs.Core.V1.ContainerArgs + { + Name = "app", + Image = "nginx:1.15-alpine", + }, + }, + }, + }, + }, + }); + var service = new Kubernetes.Core.V1.Service("service", new Kubernetes.Types.Inputs.Core.V1.ServiceArgs + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Namespace = nginxDemo.Metadata.Apply(metadata => metadata?.Name), + Labels = + { + { "app.kubernetes.io/name", "nginx-demo" }, + }, + }, + Spec = new Kubernetes.Types.Inputs.Core.V1.ServiceSpecArgs + { + Type = "ClusterIP", + Ports = + { + new Kubernetes.Types.Inputs.Core.V1.ServicePortArgs + { + Port = 80, + TargetPort = 80, + Protocol = "TCP", + }, + }, + Selector = + { + { "app.kubernetes.io/name", "nginx-demo" }, + }, + }, + }); + var ingress = new Kubernetes.Networking.V1.Ingress("ingress", new Kubernetes.Types.Inputs.Networking.V1.IngressArgs + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Namespace = nginxDemo.Metadata.Apply(metadata => metadata?.Name), + }, + Spec = new Kubernetes.Types.Inputs.Networking.V1.IngressSpecArgs + { + Rules = + { + new Kubernetes.Types.Inputs.Networking.V1.IngressRuleArgs + { + Host = hostname, + Http = new Kubernetes.Types.Inputs.Networking.V1.HTTPIngressRuleValueArgs + { + Paths = + { + new Kubernetes.Types.Inputs.Networking.V1.HTTPIngressPathArgs + { + Path = "/", + PathType = "Prefix", + Backend = new Kubernetes.Types.Inputs.Networking.V1.IngressBackendArgs + { + Service = new Kubernetes.Types.Inputs.Networking.V1.IngressServiceBackendArgs + { + Name = service.Metadata.Apply(metadata => metadata?.Name), + Port = new Kubernetes.Types.Inputs.Networking.V1.ServiceBackendPortArgs + { + Number = 80, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }); + } + +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/go/main.go new file mode 100644 index 000000000000..d5239837f3eb --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/go/main.go @@ -0,0 +1,119 @@ +package main + +import ( + appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1" + corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" + metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" + networkingv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/networking/v1" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + cfg := config.New(ctx, "") + hostname := "example.com" + if param := cfg.Get("hostname"); param != "" { + hostname = param + } + nginxdemo, err := corev1.NewNamespace(ctx, "nginxdemo", nil) + if err != nil { + return err + } + _, err = appsv1.NewDeployment(ctx, "app", &appsv1.DeploymentArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Namespace: nginxdemo.Metadata.ApplyT(func(metadata metav1.ObjectMeta) (string, error) { + return metadata.Name, nil + }).(pulumi.StringOutput), + }, + Spec: &appsv1.DeploymentSpecArgs{ + Selector: &metav1.LabelSelectorArgs{ + MatchLabels: pulumi.StringMap{ + "app.kubernetes.io/name": pulumi.String("nginx-demo"), + }, + }, + Replicas: pulumi.Int(1), + Template: &corev1.PodTemplateSpecArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Labels: pulumi.StringMap{ + "app.kubernetes.io/name": pulumi.String("nginx-demo"), + }, + }, + Spec: &corev1.PodSpecArgs{ + Containers: corev1.ContainerArray{ + &corev1.ContainerArgs{ + Name: pulumi.String("app"), + Image: pulumi.String("nginx:1.15-alpine"), + }, + }, + }, + }, + }, + }) + if err != nil { + return err + } + service, err := corev1.NewService(ctx, "service", &corev1.ServiceArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Namespace: nginxdemo.Metadata.ApplyT(func(metadata metav1.ObjectMeta) (string, error) { + return metadata.Name, nil + }).(pulumi.StringOutput), + Labels: pulumi.StringMap{ + "app.kubernetes.io/name": pulumi.String("nginx-demo"), + }, + }, + Spec: &corev1.ServiceSpecArgs{ + Type: pulumi.String("ClusterIP"), + Ports: corev1.ServicePortArray{ + &corev1.ServicePortArgs{ + Port: pulumi.Int(80), + TargetPort: pulumi.Any(80), + Protocol: pulumi.String("TCP"), + }, + }, + Selector: pulumi.StringMap{ + "app.kubernetes.io/name": pulumi.String("nginx-demo"), + }, + }, + }) + if err != nil { + return err + } + _, err = networkingv1.NewIngress(ctx, "ingress", &networkingv1.IngressArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Namespace: nginxdemo.Metadata.ApplyT(func(metadata metav1.ObjectMeta) (string, error) { + return metadata.Name, nil + }).(pulumi.StringOutput), + }, + Spec: &networkingv1.IngressSpecArgs{ + Rules: networkingv1.IngressRuleArray{ + &networkingv1.IngressRuleArgs{ + Host: pulumi.String(hostname), + Http: &networkingv1.HTTPIngressRuleValueArgs{ + Paths: networkingv1.HTTPIngressPathArray{ + &networkingv1.HTTPIngressPathArgs{ + Path: pulumi.String("/"), + PathType: pulumi.String("Prefix"), + Backend: &networkingv1.IngressBackendArgs{ + Service: &networkingv1.IngressServiceBackendArgs{ + Name: service.Metadata.ApplyT(func(metadata metav1.ObjectMeta) (string, error) { + return metadata.Name, nil + }).(pulumi.StringOutput), + Port: &networkingv1.ServiceBackendPortArgs{ + Number: pulumi.Int(80), + }, + }, + }, + }, + }, + }, + }, + }, + }, + }) + if err != nil { + return err + } + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/nodejs/index.ts new file mode 100644 index 000000000000..35e35eead395 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/nodejs/index.ts @@ -0,0 +1,75 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as kubernetes from "@pulumi/kubernetes"; + +const config = new pulumi.Config(); +const hostname = config.get("hostname") || "example.com"; +const nginxDemo = new kubernetes.core.v1.Namespace("nginx-demo", {}); +const app = new kubernetes.apps.v1.Deployment("app", { + metadata: { + namespace: nginxDemo.metadata.apply(metadata => metadata?.name), + }, + spec: { + selector: { + matchLabels: { + "app.kubernetes.io/name": "nginx-demo", + }, + }, + replicas: 1, + template: { + metadata: { + labels: { + "app.kubernetes.io/name": "nginx-demo", + }, + }, + spec: { + containers: [{ + name: "app", + image: "nginx:1.15-alpine", + }], + }, + }, + }, +}); +const service = new kubernetes.core.v1.Service("service", { + metadata: { + namespace: nginxDemo.metadata.apply(metadata => metadata?.name), + labels: { + "app.kubernetes.io/name": "nginx-demo", + }, + }, + spec: { + type: "ClusterIP", + ports: [{ + port: 80, + targetPort: 80, + protocol: "TCP", + }], + selector: { + "app.kubernetes.io/name": "nginx-demo", + }, + }, +}); +const ingress = new kubernetes.networking.v1.Ingress("ingress", { + metadata: { + namespace: nginxDemo.metadata.apply(metadata => metadata?.name), + }, + spec: { + rules: [{ + host: hostname, + http: { + paths: [{ + path: "/", + pathType: "Prefix", + backend: { + service: { + name: service.metadata.apply(metadata => metadata?.name), + port: { + number: 80, + }, + }, + }, + }], + }, + }], + }, +}); diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/program.pp new file mode 100644 index 000000000000..a243565cba82 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/program.pp @@ -0,0 +1,82 @@ +config hostname string { + default = "example.com" +} + +resource nginxDemo "kubernetes:core/v1:Namespace" { + __logicalName = "nginx-demo" +} + +resource app "kubernetes:apps/v1:Deployment" { + __logicalName = "app" + metadata = { + namespace = nginxDemo.metadata.name + } + spec = { + selector = { + matchLabels = { + "app.kubernetes.io/name" = "nginx-demo" + } + }, + replicas = 1, + template = { + metadata = { + labels = { + "app.kubernetes.io/name" = "nginx-demo" + } + }, + spec = { + containers = [{ + name = "app", + image = "nginx:1.15-alpine" + }] + } + } + } +} + +resource service "kubernetes:core/v1:Service" { + __logicalName = "service" + metadata = { + namespace = nginxDemo.metadata.name, + labels = { + "app.kubernetes.io/name" = "nginx-demo" + } + } + spec = { + type = "ClusterIP", + ports = [{ + port = 80, + targetPort = 80, + protocol = "TCP" + }], + selector = { + "app.kubernetes.io/name" = "nginx-demo" + } + } +} + +resource ingress "kubernetes:networking.k8s.io/v1:Ingress" { + __logicalName = "ingress" + metadata = { + namespace = nginxDemo.metadata.name + } + spec = { + rules = [{ + host = hostname, + http = { + paths = [{ + path = "/", + pathType = "Prefix", + backend = { + service = { + name = service.metadata.name, + port = { + number = 80 + } + } + } + }] + } + }] + } +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/python/__main__.py new file mode 100644 index 000000000000..b78791102eac --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/kubernetes/python/__main__.py @@ -0,0 +1,74 @@ +import pulumi +import pulumi_kubernetes as kubernetes + +config = pulumi.Config() +hostname = config.get("hostname") +if hostname is None: + hostname = "example.com" +nginx_demo = kubernetes.core.v1.Namespace("nginx-demo") +app = kubernetes.apps.v1.Deployment("app", + metadata=kubernetes.meta.v1.ObjectMetaArgs( + namespace=nginx_demo.metadata.name, + ), + spec=kubernetes.apps.v1.DeploymentSpecArgs( + selector=kubernetes.meta.v1.LabelSelectorArgs( + match_labels={ + "app.kubernetes.io/name": "nginx-demo", + }, + ), + replicas=1, + template=kubernetes.core.v1.PodTemplateSpecArgs( + metadata=kubernetes.meta.v1.ObjectMetaArgs( + labels={ + "app.kubernetes.io/name": "nginx-demo", + }, + ), + spec=kubernetes.core.v1.PodSpecArgs( + containers=[kubernetes.core.v1.ContainerArgs( + name="app", + image="nginx:1.15-alpine", + )], + ), + ), + )) +service = kubernetes.core.v1.Service("service", + metadata=kubernetes.meta.v1.ObjectMetaArgs( + namespace=nginx_demo.metadata.name, + labels={ + "app.kubernetes.io/name": "nginx-demo", + }, + ), + spec=kubernetes.core.v1.ServiceSpecArgs( + type="ClusterIP", + ports=[kubernetes.core.v1.ServicePortArgs( + port=80, + target_port=80, + protocol="TCP", + )], + selector={ + "app.kubernetes.io/name": "nginx-demo", + }, + )) +ingress = kubernetes.networking.v1.Ingress("ingress", + metadata=kubernetes.meta.v1.ObjectMetaArgs( + namespace=nginx_demo.metadata.name, + ), + spec=kubernetes.networking.v1.IngressSpecArgs( + rules=[kubernetes.networking.v1.IngressRuleArgs( + host=hostname, + http=kubernetes.networking.v1.HTTPIngressRuleValueArgs( + paths=[kubernetes.networking.v1.HTTPIngressPathArgs( + path="/", + path_type="Prefix", + backend=kubernetes.networking.v1.IngressBackendArgs( + service=kubernetes.networking.v1.IngressServiceBackendArgs( + name=service.metadata.name, + port=kubernetes.networking.v1.ServiceBackendPortArgs( + number=80, + ), + ), + ), + )], + ), + )], + )) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/program.pp new file mode 100644 index 000000000000..46ac1b3d5d5e --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/program.pp @@ -0,0 +1,14 @@ +output cwd0 { + __logicalName = "cwd" + value = cwd() +} + +output stack0 { + __logicalName = "stack" + value = stack() +} + +output project0 { + __logicalName = "project" + value = project() +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/python/__main__.py new file mode 100644 index 000000000000..695be4b50f1b --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/pulumi-variable/python/__main__.py @@ -0,0 +1,6 @@ +import pulumi +import os + +pulumi.export("cwd", os.getcwd()) +pulumi.export("stack", pulumi.get_stack()) +pulumi.export("project", pulumi.get_project()) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/random/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/random/go/main.go new file mode 100644 index 000000000000..5ffb43512d54 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/random/go/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + + "github.com/pulumi/pulumi-random/sdk/v4/go/random" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + randomPassword, err := random.NewRandomPassword(ctx, "randomPassword", &random.RandomPasswordArgs{ + Length: pulumi.Int(16), + Special: pulumi.Bool(true), + OverrideSpecial: pulumi.String(fmt.Sprintf("_%v@", "%")), + }) + if err != nil { + return err + } + ctx.Export("password", randomPassword.Result) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/random/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/random/program.pp new file mode 100644 index 000000000000..3bd1c5cdf81f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/random/program.pp @@ -0,0 +1,11 @@ +resource randomPassword "random:index/randomPassword:RandomPassword" { + __logicalName = "randomPassword" + length = 16 + special = true + overrideSpecial = "_%@" +} + +output password { + __logicalName = "password" + value = randomPassword.result +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/random/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/random/python/__main__.py new file mode 100644 index 000000000000..aa99a4f8581f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/random/python/__main__.py @@ -0,0 +1,8 @@ +import pulumi +import pulumi_random as random + +random_password = random.RandomPassword("randomPassword", + length=16, + special=True, + override_special="_%@") +pulumi.export("password", random_password.result) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/readme/go/main.go b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/go/main.go new file mode 100644 index 000000000000..023fcea4d226 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/go/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "io/ioutil" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func readFileOrPanic(path string) pulumi.StringPtrInput { + data, err := ioutil.ReadFile(path) + if err != nil { + panic(err.Error()) + } + return pulumi.String(string(data)) +} + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + ctx.Export("strVar", "foo") + ctx.Export("arrVar", []string{ + "fizz", + "buzz", + }) + ctx.Export("readme", readFileOrPanic("./Pulumi.README.md")) + return nil + }) +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/readme/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/nodejs/index.ts new file mode 100644 index 000000000000..cb88b5816c72 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/nodejs/index.ts @@ -0,0 +1,9 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as fs from "fs"; + +export const strVar = "foo"; +export const arrVar = [ + "fizz", + "buzz", +]; +export const readme = fs.readFileSync("./Pulumi.README.md"); diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/readme/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/program.pp new file mode 100644 index 000000000000..9550599ee08c --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/program.pp @@ -0,0 +1,17 @@ +output strVar { + __logicalName = "strVar" + value = "foo" +} + +output arrVar { + __logicalName = "arrVar" + value = [ + "fizz", + "buzz" + ] +} + +output readme { + __logicalName = "readme" + value = readFile("./Pulumi.README.md") +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/readme/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/python/__main__.py new file mode 100644 index 000000000000..cda4c838980f --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/readme/python/__main__.py @@ -0,0 +1,8 @@ +import pulumi + +pulumi.export("strVar", "foo") +pulumi.export("arrVar", [ + "fizz", + "buzz", +]) +pulumi.export("readme", (lambda path: open(path).read())("./Pulumi.README.md")) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/program.pp new file mode 100644 index 000000000000..5b036d85bfe0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/program.pp @@ -0,0 +1,6 @@ +stackReference placeholder_org_namEstackreferenceproducerPLACEHOLDER_STACK_NAME "PLACEHOLDER_ORG_NAME/stackreference-producer/PLACEHOLDER_STACK_NAME" { +} + +output referencedImageName { + value = placeholder_org_namEstackreferenceproducerPLACEHOLDER_STACK_NAME.outputs["imageName"] +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/python/__main__.py new file mode 100644 index 000000000000..0e2730e7f3c6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-consumer/python/__main__.py @@ -0,0 +1,3 @@ +import pulumi + +pulumi.export("referencedImageName", placeholder_org_nam_estackreferenceproducer_placeholde_r__stac_k__name["outputs"]["imageName"]) diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/nodejs/index.ts new file mode 100644 index 000000000000..12116586a2c1 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/nodejs/index.ts @@ -0,0 +1,3 @@ +import * as pulumi from "@pulumi/pulumi"; + +export const imageName = "pulumi/pulumi:latest"; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/program.pp new file mode 100644 index 000000000000..6c055783d525 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/program.pp @@ -0,0 +1,4 @@ +output imageName { + __logicalName = "imageName" + value = "pulumi/pulumi:latest" +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/python/__main__.py b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/python/__main__.py new file mode 100644 index 000000000000..f53d357111dd --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/stackreference-producer/python/__main__.py @@ -0,0 +1,3 @@ +import pulumi + +pulumi.export("imageName", "pulumi/pulumi:latest") diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/nodejs/index.ts new file mode 100644 index 000000000000..88aa1e1ef3a9 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/nodejs/index.ts @@ -0,0 +1,31 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; + +const config = new pulumi.Config(); +const instanceType = config.get("instanceType") || "t3.micro"; +const webSecGrp = new aws.ec2.SecurityGroup("WebSecGrp", {ingress: [{ + protocol: "tcp", + fromPort: 80, + toPort: 80, + cidrBlocks: ["0.0.0.0/0"], +}]}); +const webServer = new aws.ec2.Instance("WebServer", { + instanceType: instanceType, + ami: aws.getAmi({ + filters: [{ + name: "name", + values: ["amzn-ami-hvm-*-x86_64-ebs"], + }], + owners: ["137112412989"], + mostRecent: true, + }).then(invoke => invoke.id), + userData: webSecGrp.arn.apply(arn => [ + "#!/bin/bash", + `echo 'Hello, World from ${arn}!' > index.html`, + "nohup python -m SimpleHTTPServer 80 &", + ].join("\n")), + vpcSecurityGroupIds: [webSecGrp.id], +}); +export const instanceId = webServer.id; +export const publicIp = webServer.publicIp; +export const publicHostName = webServer.publicDns; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/program.pp new file mode 100644 index 000000000000..655724d85042 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver-json/program.pp @@ -0,0 +1,47 @@ +config instanceType string { + default = "t3.micro" +} + +resource webSecGrp "aws:ec2/securityGroup:SecurityGroup" { + __logicalName = "WebSecGrp" + ingress = [{ + protocol = "tcp", + fromPort = 80, + toPort = 80, + cidrBlocks = ["0.0.0.0/0"] + }] +} + +resource webServer "aws:ec2/instance:Instance" { + __logicalName = "WebServer" + instanceType = instanceType + ami = invoke("aws:index/getAmi:getAmi", { + filters = [{ + name = "name", + values = ["amzn-ami-hvm-*-x86_64-ebs"] + }], + owners = ["137112412989"], + mostRecent = true + }).id + userData = join("\n", [ + "#!/bin/bash", + "echo 'Hello, World from ${webSecGrp.arn}!' > index.html", + "nohup python -m SimpleHTTPServer 80 &" + ]) + vpcSecurityGroupIds = [webSecGrp.id] +} + +output instanceId { + __logicalName = "InstanceId" + value = webServer.id +} + +output publicIp { + __logicalName = "PublicIp" + value = webServer.publicIp +} + +output publicHostName { + __logicalName = "PublicHostName" + value = webServer.publicDns +} diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/nodejs/index.ts b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/nodejs/index.ts new file mode 100644 index 000000000000..fa689e24d60e --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/nodejs/index.ts @@ -0,0 +1,34 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; + +const config = new pulumi.Config(); +const instanceType = config.get("instanceType") || "t3.micro"; +const ec2Ami = aws.getAmi({ + filters: [{ + name: "name", + values: ["amzn-ami-hvm-*-x86_64-ebs"], + }], + owners: ["137112412989"], + mostRecent: true, +}).then(invoke => invoke.id); +const webSecGrp = new aws.ec2.SecurityGroup("WebSecGrp", {ingress: [{ + protocol: "tcp", + fromPort: 80, + toPort: 80, + cidrBlocks: ["0.0.0.0/0"], +}]}); +const webServer = new aws.ec2.Instance("WebServer", { + instanceType: instanceType, + ami: ec2Ami, + userData: pulumi.interpolate`#!/bin/bash +echo 'Hello, World from ${webSecGrp.arn}!' > index.html +nohup python -m SimpleHTTPServer 80 &`, + vpcSecurityGroupIds: [webSecGrp.id], +}); +const usEast2Provider = new aws.Provider("UsEast2Provider", {region: "us-east-2"}); +const myBucket = new aws.s3.Bucket("MyBucket", {}, { + provider: usEast2Provider, +}); +export const instanceId = webServer.id; +export const publicIp = webServer.publicIp; +export const publicHostName = webServer.publicDns; diff --git a/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/program.pp b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/program.pp new file mode 100644 index 000000000000..233a861db526 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/transpiled_examples/webserver/program.pp @@ -0,0 +1,58 @@ +config instanceType string { + default = "t3.micro" +} + +ec2Ami = invoke("aws:index/getAmi:getAmi", { + filters = [{ + name = "name", + values = ["amzn-ami-hvm-*-x86_64-ebs"] + }], + owners = ["137112412989"], + mostRecent = true +}).id + +resource webSecGrp "aws:ec2/securityGroup:SecurityGroup" { + __logicalName = "WebSecGrp" + ingress = [{ + protocol = "tcp", + fromPort = 80, + toPort = 80, + cidrBlocks = ["0.0.0.0/0"] + }] +} + +resource webServer "aws:ec2/instance:Instance" { + __logicalName = "WebServer" + instanceType = instanceType + ami = ec2Ami + userData = "#!/bin/bash\necho 'Hello, World from ${webSecGrp.arn}!' > index.html\nnohup python -m SimpleHTTPServer 80 &" + vpcSecurityGroupIds = [webSecGrp.id] +} + +resource usEast2Provider "pulumi:providers:aws" { + __logicalName = "UsEast2Provider" + region = "us-east-2" +} + +resource myBucket "aws:s3/bucket:Bucket" { + __logicalName = "MyBucket" + + options { + provider = usEast2Provider + } +} + +output instanceId { + __logicalName = "InstanceId" + value = webServer.id +} + +output publicIp { + __logicalName = "PublicIp" + value = webServer.publicIp +} + +output publicHostName { + __logicalName = "PublicHostName" + value = webServer.publicDns +}