From 58cec66a46998ef35d8b063a602078d060c764ca Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Tue, 1 Aug 2023 14:11:25 -0700 Subject: [PATCH] Pull testdata and schemas, regenerate, opt-out broken tests Gets the latest testdata with `make get_testdata`, updates `get_schemas.sh` with schemas referenced by these tests, and runs codegen to regenerate all cases. Broken tests were opted out, with the following issues created for them. - https://github.com/pulumi/pulumi-yaml/issues/476 - https://github.com/pulumi/pulumi-yaml/issues/477 - https://github.com/pulumi/pulumi-yaml/issues/478 - https://github.com/pulumi/pulumi-yaml/issues/479 - https://github.com/pulumi/pulumi-yaml/issues/480 --- pkg/pulumiyaml/codegen/gen_program_test.go | 25 +++- .../aws-fargate-output-versioned.pp | 108 +++++++++++++++++ .../yaml/aws-fargate-output-versioned.yaml | 114 ++++++++++++++++++ .../test/testdata/azure-sa-pp/azure-sa.pp | 2 + .../components-pp/another-component/main.pp | 4 + .../test/testdata/components-pp/components.pp | 33 +++++ .../components-pp/exampleComponent/main.pp | 58 +++++++++ .../components-pp/simpleComponent/main.pp | 9 ++ .../dynamic-entries-pp/dynamic-entries.pp | 20 +++ .../entries-function-pp/entries-function.pp | 4 + .../test/testdata/functions-pp/functions.pp | 9 +- .../interpolated-string-keys.pp | 7 ++ .../invoke-inside-conditional-range.pp | 67 ++++++++++ .../iterating-optional-range-expressions.pp | 40 ++++++ .../kubernetes-pod-pp/kubernetes-pod.pp | 11 ++ .../yaml/kubernetes-pod.yaml | 8 ++ .../testdata/logical-name-pp/logical-name.pp | 6 + .../multiline-string-pp/multiline-string.pp | 19 +++ .../yaml/multiline-string.yaml | 27 +++++ .../optional-complex-config.pp | 36 ++++++ .../output-literals-pp/output-literals.pp | 15 +++ .../yaml/output-literals.yaml | 5 + .../output-name-conflict.pp | 7 ++ .../yaml/output-name-conflict.yaml | 6 + .../python-reserved-pp/python-reserved.pp | 7 ++ .../regress-11176-pp/regress-11176.pp | 4 + .../regress-11176-pp/yaml/regress-11176.yaml | 7 ++ .../retain-on-delete-pp/retain-on-delete.pp | 5 + .../yaml/retain-on-delete.yaml | 4 + .../testdata/simple-range-pp/simple-range.pp | 16 ++- .../testdata/simple-splat-pp/simple-splat.pp | 5 + .../simplified-invokes.pp | 23 ++++ .../single-or-none-pp/single-or-none.pp | 3 + .../snowflake-python-12998.pp | 7 ++ .../throw-not-implemented.pp | 3 + .../unknown-invoke-pp/unknown-invoke.pp | 9 ++ .../yaml/unknown-invoke.yaml | 12 ++ .../unknown-resource-pp/unknown-resource.pp | 21 ++++ .../testdata/using-dashes-pp/using-dashes.pp | 3 + .../using-dashes-pp/yaml/using-dashes.yaml | 5 + scripts/get_schemas.sh | 4 + 41 files changed, 767 insertions(+), 11 deletions(-) create mode 100644 pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/aws-fargate-output-versioned.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/yaml/aws-fargate-output-versioned.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/components-pp/another-component/main.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/components-pp/components.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/components-pp/exampleComponent/main.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/components-pp/simpleComponent/main.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/dynamic-entries-pp/dynamic-entries.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/entries-function-pp/entries-function.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/interpolated-string-keys-pp/interpolated-string-keys.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/invoke-inside-conditional-range-pp/invoke-inside-conditional-range.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/iterating-optional-range-expressions-pp/iterating-optional-range-expressions.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/multiline-string.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/yaml/multiline-string.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/optional-complex-config-pp/optional-complex-config.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/output-literals-pp/output-literals.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/output-literals-pp/yaml/output-literals.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/output-name-conflict.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/yaml/output-name-conflict.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/python-reserved-pp/python-reserved.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/regress-11176.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/yaml/regress-11176.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/retain-on-delete.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/yaml/retain-on-delete.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/simple-splat-pp/simple-splat.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/simplified-invokes-pp/simplified-invokes.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/single-or-none-pp/single-or-none.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/snowflake-python-12998-pp/snowflake-python-12998.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/throw-not-implemented-pp/throw-not-implemented.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/unknown-invoke.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/yaml/unknown-invoke.yaml create mode 100644 pkg/pulumiyaml/testing/test/testdata/unknown-resource-pp/unknown-resource.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/using-dashes.pp create mode 100644 pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/yaml/using-dashes.yaml diff --git a/pkg/pulumiyaml/codegen/gen_program_test.go b/pkg/pulumiyaml/codegen/gen_program_test.go index 3a52cd85..b7b51d3b 100644 --- a/pkg/pulumiyaml/codegen/gen_program_test.go +++ b/pkg/pulumiyaml/codegen/gen_program_test.go @@ -164,17 +164,34 @@ func TestGenerateProgram(t *testing.T) { // https://github.com/pulumi/pulumi-yaml/issues/229 case "azure-sa": // Reason: has dependencies between config variables - case "aws-eks", "aws-s3-folder": + case "aws-eks", "aws-s3-folder", "simple-splat": // Reason: missing splat // // Note: aws-s3-folder errors with // 14,27-52: the asset parameter must be a string literal; the asset parameter must be a string literal // But the actual error is that it is using a Splat operator. - case "python-resource-names": + case "components": + // https://github.com/pulumi/pulumi-yaml/issues/476 + case "logical-name": + // https://github.com/pulumi/pulumi-yaml/issues/477 + case "unknown-resource": + // https://github.com/pulumi/pulumi-yaml/issues/478 + case "optional-complex-config": + // https://github.com/pulumi/pulumi-yaml/issues/479 + case "interpolated-string-keys": + // https://github.com/pulumi/pulumi-yaml/issues/480 + case "functions", "throw-not-implemented", "single-or-none": + // Pulumi YAML does not functions: + // secret or unsecret, notImplemented, singleOrNone. + case "python-resource-names", "python-reserved", "snowflake-python-12998": // Reason: A python only test. - case "simple-range": + case "simple-range", "entries-function", + "iterating-optional-range-expressions", + "invoke-inside-conditional-range": // Pulumi YAML does not support ranges - case "read-file-func", "python-regress-10914": + case "dynamic-entries": + // Pulumi YAML does not support for loops. + case "read-file-func", "python-regress-10914", "unknown-invoke": tt.SkipCompile = codegen.NewStringSet("yaml") l = append(l, tt) case "traverse-union-repro": diff --git a/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/aws-fargate-output-versioned.pp b/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/aws-fargate-output-versioned.pp new file mode 100644 index 00000000..2e558ca3 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/aws-fargate-output-versioned.pp @@ -0,0 +1,108 @@ +// Read the default VPC and public subnets, which we will use. +vpc = invoke("aws:ec2:getVpc", { + default = true +}) +subnets = invoke("aws:ec2:getSubnetIds", { + vpcId = vpc.id +}) + +// Create a security group that permits HTTP ingress and unrestricted egress. +resource webSecurityGroup "aws:ec2:SecurityGroup" { + vpcId = vpc.id + egress = [{ + protocol = "-1" + fromPort = 0 + toPort = 0 + cidrBlocks = ["0.0.0.0/0"] + }] + ingress = [{ + protocol = "tcp" + fromPort = 80 + toPort = 80 + cidrBlocks = ["0.0.0.0/0"] + }] +} + +// Create an ECS cluster to run a container-based service. +resource cluster "aws:ecs:Cluster" {} + +// Create an IAM role that can be used by our service's task. +resource taskExecRole "aws:iam:Role" { + assumeRolePolicy = toJSON({ + Version = "2008-10-17" + Statement = [{ + Sid = "" + Effect = "Allow" + Principal = { + Service = "ecs-tasks.amazonaws.com" + } + Action = "sts:AssumeRole" + }] + }) +} +resource taskExecRolePolicyAttachment "aws:iam:RolePolicyAttachment" { + role = taskExecRole.name + policyArn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" +} + +// Create a load balancer to listen for HTTP traffic on port 80. +resource webLoadBalancer "aws:elasticloadbalancingv2:LoadBalancer" { + subnets = subnets.ids + securityGroups = [webSecurityGroup.id] +} +resource webTargetGroup "aws:elasticloadbalancingv2:TargetGroup" { + port = 80 + protocol = "HTTP" + targetType = "ip" + vpcId = vpc.id +} +resource webListener "aws:elasticloadbalancingv2:Listener" { + loadBalancerArn = webLoadBalancer.arn + port = 80 + defaultActions = [{ + type = "forward" + targetGroupArn = webTargetGroup.arn + }] +} + +// Spin up a load balanced service running NGINX +resource appTask "aws:ecs:TaskDefinition" { + family = "fargate-task-definition" + cpu = "256" + memory = "512" + networkMode = "awsvpc" + requiresCompatibilities = ["FARGATE"] + executionRoleArn = taskExecRole.arn + containerDefinitions = toJSON([{ + name = "my-app" + image = "nginx" + portMappings = [{ + containerPort = 80 + hostPort = 80 + protocol = "tcp" + }] + }]) +} +resource appService "aws:ecs:Service" { + cluster = cluster.arn + desiredCount = 5 + launchType = "FARGATE" + taskDefinition = appTask.arn + networkConfiguration = { + assignPublicIp = true + subnets = subnets.ids + securityGroups = [webSecurityGroup.id] + } + loadBalancers = [{ + targetGroupArn = webTargetGroup.arn + containerName = "my-app" + containerPort = 80 + }] + + options { + dependsOn = [webListener] + } +} + +// Export the resulting web address. +output url { value = webLoadBalancer.dnsName } diff --git a/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/yaml/aws-fargate-output-versioned.yaml b/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/yaml/aws-fargate-output-versioned.yaml new file mode 100644 index 00000000..ee9a44ef --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/aws-fargate-output-versioned-pp/yaml/aws-fargate-output-versioned.yaml @@ -0,0 +1,114 @@ +resources: + # Create a security group that permits HTTP ingress and unrestricted egress. + webSecurityGroup: + type: aws:ec2:SecurityGroup + properties: + vpcId: ${vpc.id} + egress: + - protocol: '-1' + fromPort: 0 + toPort: 0 + cidrBlocks: + - 0.0.0.0/0 + ingress: + - protocol: tcp + fromPort: 80 + toPort: 80 + cidrBlocks: + - 0.0.0.0/0 + # Create an ECS cluster to run a container-based service. + cluster: + type: aws:ecs:Cluster + # Create an IAM role that can be used by our service's task. + taskExecRole: + type: aws:iam:Role + properties: + assumeRolePolicy: + fn::toJSON: + Version: 2008-10-17 + Statement: + - Sid: + Effect: Allow + Principal: + Service: ecs-tasks.amazonaws.com + Action: sts:AssumeRole + taskExecRolePolicyAttachment: + type: aws:iam:RolePolicyAttachment + properties: + role: ${taskExecRole.name} + policyArn: arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy + # Create a load balancer to listen for HTTP traffic on port 80. + webLoadBalancer: + type: aws:elasticloadbalancingv2:LoadBalancer + properties: + subnets: ${subnets.ids} + securityGroups: + - ${webSecurityGroup.id} + webTargetGroup: + type: aws:elasticloadbalancingv2:TargetGroup + properties: + port: 80 + protocol: HTTP + targetType: ip + vpcId: ${vpc.id} + webListener: + type: aws:elasticloadbalancingv2:Listener + properties: + loadBalancerArn: ${webLoadBalancer.arn} + port: 80 + defaultActions: + - type: forward + targetGroupArn: ${webTargetGroup.arn} + # Spin up a load balanced service running NGINX + appTask: + type: aws:ecs:TaskDefinition + properties: + family: fargate-task-definition + cpu: '256' + memory: '512' + networkMode: awsvpc + requiresCompatibilities: + - FARGATE + executionRoleArn: ${taskExecRole.arn} + containerDefinitions: + fn::toJSON: + - name: my-app + image: nginx + portMappings: + - containerPort: 80 + hostPort: 80 + protocol: tcp + appService: + type: aws:ecs:Service + properties: + cluster: ${cluster.arn} + desiredCount: 5 + launchType: FARGATE + taskDefinition: ${appTask.arn} + networkConfiguration: + assignPublicIp: true + subnets: ${subnets.ids} + securityGroups: + - ${webSecurityGroup.id} + loadBalancers: + - targetGroupArn: ${webTargetGroup.arn} + containerName: my-app + containerPort: 80 + options: + dependson: + - ${webListener} +variables: + # Read the default VPC and public subnets, which we will use. + vpc: + fn::invoke: + Function: aws:ec2:getVpc + Arguments: + default: true + subnets: + fn::invoke: + Function: aws:ec2:getSubnetIds + Arguments: + vpcId: ${vpc.id} +outputs: + # Export the resulting web address. + url: ${webLoadBalancer.dnsName} diff --git a/pkg/pulumiyaml/testing/test/testdata/azure-sa-pp/azure-sa.pp b/pkg/pulumiyaml/testing/test/testdata/azure-sa-pp/azure-sa.pp index 806bca02..92947313 100644 --- a/pkg/pulumiyaml/testing/test/testdata/azure-sa-pp/azure-sa.pp +++ b/pkg/pulumiyaml/testing/test/testdata/azure-sa-pp/azure-sa.pp @@ -1,7 +1,9 @@ config storageAccountNameParam string { + description = "The name of the storage account" } config resourceGroupNameParam string { + description = "The name of the resource group" } resourceGroupVar = invoke("azure:core/getResourceGroup:getResourceGroup", { diff --git a/pkg/pulumiyaml/testing/test/testdata/components-pp/another-component/main.pp b/pkg/pulumiyaml/testing/test/testdata/components-pp/another-component/main.pp new file mode 100644 index 00000000..d09a49fd --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/components-pp/another-component/main.pp @@ -0,0 +1,4 @@ +resource firstPassword "random:index/randomPassword:RandomPassword" { + length = 16 + special = true +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/components-pp/components.pp b/pkg/pulumiyaml/testing/test/testdata/components-pp/components.pp new file mode 100644 index 00000000..d1e612f3 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/components-pp/components.pp @@ -0,0 +1,33 @@ +component simpleComponent "./simpleComponent" {} + +component anotherComponent "./another-component" {} + +component exampleComponent "./exampleComponent" { + input = "doggo" + ipAddress = [127, 0, 0, 1] + cidrBlocks = { + "one" = "uno" + "two" = "dos" + } + githubApp = { + id = "example id" + keyBase64 = "base64 encoded key" + webhookSecret = "very important secret" + } + servers = [ + { name = "First" }, + { name = "Second" } + ] + deploymentZones = { + "first" = { + zone = "First zone" + }, + "second" = { + zone = "Second zone" + } + } +} + +output result { + value = exampleComponent.result +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/components-pp/exampleComponent/main.pp b/pkg/pulumiyaml/testing/test/testdata/components-pp/exampleComponent/main.pp new file mode 100644 index 00000000..48db3bab --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/components-pp/exampleComponent/main.pp @@ -0,0 +1,58 @@ +config input string { + description = "A simple input" +} + +config cidrBlocks "map(string)" { + description = "The main CIDR blocks for the VPC\nIt is a map of strings" +} + +config "githubApp" "object({id=string, keyBase64=string,webhookSecret=string})" { + description = "GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`)." + nullable = true +} + +config "servers" "list(object({name=string}))" { + description = "A list of servers" + nullable = true +} + +config "deploymentZones" "map(object({ zone = string }))" { + description = "A map between for zones" + nullable = true +} + +config ipAddress "list(int)" { } + +resource password "random:index/randomPassword:RandomPassword" { + length = 16 + special = true + overrideSpecial = input +} + +resource githubPassword "random:index/randomPassword:RandomPassword" { + length = 16 + special = true + overrideSpecial = githubApp.webhookSecret +} + +# Example of iterating a list of objects +resource serverPasswords "random:index/randomPassword:RandomPassword" { + options { range = length(servers) } + length = 16 + special = true + overrideSpecial = servers[range.value].name +} + +# Example of iterating a map of objects +resource zonePasswords "random:index/randomPassword:RandomPassword" { + options { range = deploymentZones } + length = 16 + special = true + overrideSpecial = range.value.zone +} + +component simpleComponent "../simpleComponent" {} + +output result { + value = password.result +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/components-pp/simpleComponent/main.pp b/pkg/pulumiyaml/testing/test/testdata/components-pp/simpleComponent/main.pp new file mode 100644 index 00000000..3c20f783 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/components-pp/simpleComponent/main.pp @@ -0,0 +1,9 @@ +resource firstPassword "random:index/randomPassword:RandomPassword" { + length = 16 + special = true +} + +resource secondPassword "random:index/randomPassword:RandomPassword" { + length = 16 + special = true +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/dynamic-entries-pp/dynamic-entries.pp b/pkg/pulumiyaml/testing/test/testdata/dynamic-entries-pp/dynamic-entries.pp new file mode 100644 index 00000000..73c51412 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/dynamic-entries-pp/dynamic-entries.pp @@ -0,0 +1,20 @@ +config "domainName" "string" { + default = "" + description = "A domain name for which the certificate should be issued" +} +config "validationMethod" "string" { + default = "DNS" + description = "Which method to use for validation. DNS or EMAIL are valid, NONE can be used for certificates that were imported into ACM and then into Terraform." +} +config "validationOption" "any" { + default = {} +} + +resource "certificate" "aws:acm/certificate:Certificate" { + validationOptions = [for entry in entries(validationOption) : { + domainName = entry.value["domain_name"] + validationDomain = entry.value["validation_domain"] + }] + domainName = domainName + validationMethod = validationMethod +} diff --git a/pkg/pulumiyaml/testing/test/testdata/entries-function-pp/entries-function.pp b/pkg/pulumiyaml/testing/test/testdata/entries-function-pp/entries-function.pp new file mode 100644 index 00000000..e7ae7a43 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/entries-function-pp/entries-function.pp @@ -0,0 +1,4 @@ +data = [for entry in entries([1,2,3]) : { + usingKey: entry.key + usingValue: entry.value +}] \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/functions-pp/functions.pp b/pkg/pulumiyaml/testing/test/testdata/functions-pp/functions.pp index 76c0bfdb..29cbd1d1 100644 --- a/pkg/pulumiyaml/testing/test/testdata/functions-pp/functions.pp +++ b/pkg/pulumiyaml/testing/test/testdata/functions-pp/functions.pp @@ -4,10 +4,17 @@ joined = join("-", [encoded, decoded, "2"]) +# tests that we initialize "var, err" with ":=" first, then "=" subsequently (Go specific) +zone = invoke("aws:index:getAvailabilityZones", {}) +zone2 = invoke("aws:index:getAvailabilityZones", {}) + resource bucket "aws:s3:Bucket" { } encoded2 = toBase64(bucket.id) -decoded2 = fromBase64(encoded2) +decoded2 = fromBase64(bucket.id) + +secretValue = secret("hello") +plainValue = unsecret(secretValue) diff --git a/pkg/pulumiyaml/testing/test/testdata/interpolated-string-keys-pp/interpolated-string-keys.pp b/pkg/pulumiyaml/testing/test/testdata/interpolated-string-keys-pp/interpolated-string-keys.pp new file mode 100644 index 00000000..1e59f5ef --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/interpolated-string-keys-pp/interpolated-string-keys.pp @@ -0,0 +1,7 @@ +config value "string" {} + +config tags "map(string)" { + default = { + "interpolated/${value}" = "value" + } +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/invoke-inside-conditional-range-pp/invoke-inside-conditional-range.pp b/pkg/pulumiyaml/testing/test/testdata/invoke-inside-conditional-range-pp/invoke-inside-conditional-range.pp new file mode 100644 index 00000000..d3915506 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/invoke-inside-conditional-range-pp/invoke-inside-conditional-range.pp @@ -0,0 +1,67 @@ +config "azs" "list(string)" { + default = [] + description = "A list of availability zones names or ids in the region" +} + +config "publicSubnetIpv6Prefixes" "list(string)" { + default = [] + description = "Assigns IPv6 public subnet id based on the Amazon provided /56 prefix base 10 integer (0-256). Must be of equal length to the corresponding IPv4 subnet list" +} +config "oneNatGatewayPerAz" "bool" { + default = false + description = "Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`" +} + +config "enableIpv6" "bool" { + default = false + description = "Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block" +} + +config "publicSubnetIpv6Native" "bool" { + default = false + description = "Indicates whether to create an IPv6-only subnet. Default: `false`" +} + +config "publicSubnetEnableDns64" "bool" { + default = true + description = "Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. Default: `true`" +} + +config "publicSubnetAssignIpv6AddressOnCreation" "bool" { + default = false + description = "Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is `false`" +} + +config "publicSubnetEnableResourceNameDnsAaaaRecordOnLaunch" "bool" { + default = true + description = "Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: `true`" +} + +config "publicSubnetEnableResourceNameDnsARecordOnLaunch" "bool" { + default = false + description = "Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: `false`" +} + +lenPublicSubnets = invoke("std:index:max", { + input = [1, 2, 3] +}).result + +resource "currentVpc" "aws:ec2/vpc:Vpc" {} + +createPublicSubnets = true +resource "publicSubnet" "aws:ec2/subnet:Subnet" { + options { + range = createPublicSubnets && (!oneNatGatewayPerAz || lenPublicSubnets >= length(azs)) ? lenPublicSubnets : 0 + } + assignIpv6AddressOnCreation = enableIpv6 && publicSubnetIpv6Native ? true : publicSubnetAssignIpv6AddressOnCreation + enableDns64 = enableIpv6 && publicSubnetEnableDns64 + enableResourceNameDnsAaaaRecordOnLaunch = enableIpv6 && publicSubnetEnableResourceNameDnsAaaaRecordOnLaunch + enableResourceNameDnsARecordOnLaunch = !publicSubnetIpv6Native && publicSubnetEnableResourceNameDnsARecordOnLaunch + ipv6CidrBlock = enableIpv6 && length(publicSubnetIpv6Prefixes) > 0 ? invoke("std:index:cidrsubnet", { + input = currentVpc.ipv6CidrBlock + newbits = 8 + netnum = publicSubnetIpv6Prefixes[range.value] + }).result : null + ipv6Native = enableIpv6 && publicSubnetIpv6Native + vpcId = currentVpc.id +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/iterating-optional-range-expressions-pp/iterating-optional-range-expressions.pp b/pkg/pulumiyaml/testing/test/testdata/iterating-optional-range-expressions-pp/iterating-optional-range-expressions.pp new file mode 100644 index 00000000..af31b630 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/iterating-optional-range-expressions-pp/iterating-optional-range-expressions.pp @@ -0,0 +1,40 @@ +resource "root" "range:index:Root" {} + +// creating resources by iterating a property of type array(string) of another resource +resource "fromListOfStrings" "range:index:Example" { + options { + range = root.arrayOfString + } + + someString = range.value +} + +// creating resources by iterating a property of type map(string) of another resource +resource "fromMapOfStrings" "range:index:Example" { + options { + range = root.mapOfString + } + + someString = "${range.key} ${range.value}" +} + +// computed range list expression to create instances of range:index:Example resource +resource "fromComputedListOfStrings" "range:index:Example" { + options { + range = [ + root.mapOfString["hello"], + root.mapOfString["world"] + ] + } + + someString = "${range.key} ${range.value}" +} + +// computed range for expression to create instances of range:index:Example resource +resource "fromComputedForExpression" "range:index:Example" { + options { + range = [for value in root.arrayOfString : root.mapOfString[value]] + } + + someString = "${range.key} ${range.value}" +} diff --git a/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/kubernetes-pod.pp b/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/kubernetes-pod.pp index 4751e7b0..9785f103 100644 --- a/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/kubernetes-pod.pp +++ b/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/kubernetes-pod.pp @@ -16,6 +16,17 @@ cpu = 0.2 } } + }, + { + name = "nginx2" + image = "nginx:1.14-alpine" + ports = [{ containerPort = 80 }] + resources = { + limits = { + memory = "20Mi" + cpu = 0.2 + } + } } ] } diff --git a/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/yaml/kubernetes-pod.yaml b/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/yaml/kubernetes-pod.yaml index e0efb994..86968e23 100644 --- a/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/yaml/kubernetes-pod.yaml +++ b/pkg/pulumiyaml/testing/test/testdata/kubernetes-pod-pp/yaml/kubernetes-pod.yaml @@ -16,6 +16,14 @@ resources: limits: memory: 20Mi cpu: 0.2 + - name: nginx2 + image: nginx:1.14-alpine + ports: + - containerPort: 80 + resources: + limits: + memory: 20Mi + cpu: 0.2 variables: # Test that we can assign from a constant without type errors kind: ${bar.kind} diff --git a/pkg/pulumiyaml/testing/test/testdata/logical-name-pp/logical-name.pp b/pkg/pulumiyaml/testing/test/testdata/logical-name-pp/logical-name.pp index 59f6a196..ee9c8da6 100644 --- a/pkg/pulumiyaml/testing/test/testdata/logical-name-pp/logical-name.pp +++ b/pkg/pulumiyaml/testing/test/testdata/logical-name-pp/logical-name.pp @@ -1,6 +1,12 @@ +config configLexicalName string { + __logicalName = "cC-Charlie_charlie.😃⁉️" +} + resource resourceLexicalName "random:index/randomPet:RandomPet" { // not necessarily a valid logical name, just testing that it passes through to codegen unmodified __logicalName = "aA-Alpha_alpha.🤯⁉️" + + prefix = configLexicalName } output outputLexicalName { diff --git a/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/multiline-string.pp b/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/multiline-string.pp new file mode 100644 index 00000000..06bf70f3 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/multiline-string.pp @@ -0,0 +1,19 @@ +resource foo "random:index/randomShuffle:RandomShuffle" { + inputs = [ + "just one\nnewline", + "foo\nbar\nbaz\nqux\nquux\nqux", + <<-EOT + { + "a": 1, + "b": 2, + "c": [ + "foo", + "bar", + "baz", + "qux", + "quux" + ] + } + EOT + ] +} diff --git a/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/yaml/multiline-string.yaml b/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/yaml/multiline-string.yaml new file mode 100644 index 00000000..a26685e5 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/multiline-string-pp/yaml/multiline-string.yaml @@ -0,0 +1,27 @@ +resources: + foo: + type: random:RandomShuffle + properties: + inputs: + - |- + just one + newline + - |- + foo + bar + baz + qux + quux + qux + - | + { + "a": 1, + "b": 2, + "c": [ + "foo", + "bar", + "baz", + "qux", + "quux" + ] + } diff --git a/pkg/pulumiyaml/testing/test/testdata/optional-complex-config-pp/optional-complex-config.pp b/pkg/pulumiyaml/testing/test/testdata/optional-complex-config-pp/optional-complex-config.pp new file mode 100644 index 00000000..df4c5e8b --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/optional-complex-config-pp/optional-complex-config.pp @@ -0,0 +1,36 @@ +config "vpcTag" "string" { + default = null + description = "The tag of the VPC" +} + +config "vpcId" "string" { + default = null + description = "The id of a VPC to use instead of creating a new one" +} + +config "subnets" "list(string)" { + default = null + description = "The list of subnets to use" +} + +config moreTags "map(string)" { + default = null + description = "Additional tags to add to the VPC" +} + +config userdata "object({path=string, content=string})" { + default = null + description = "The userdata to use for the instances" +} + +config complexUserdata "list(object({path=string, content=string}))" { + default = null + description = "A complex object" +} + +resource main "aws:ec2:Vpc" { + cidrBlock = "10.100.0.0/16" + tags = { + "Name": vpcTag + } +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/output-literals.pp b/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/output-literals.pp new file mode 100644 index 00000000..6a14978e --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/output-literals.pp @@ -0,0 +1,15 @@ +output "output_true" "bool" { + value = true +} + +output "output_false" "bool" { + value = false +} + +output "output_number" "number" { + value = 4 +} + +output "output_string" "string" { + value = "hello" +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/yaml/output-literals.yaml b/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/yaml/output-literals.yaml new file mode 100644 index 00000000..28551d51 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/output-literals-pp/yaml/output-literals.yaml @@ -0,0 +1,5 @@ +outputs: + output_true: true + output_false: false + output_number: 4 + output_string: hello diff --git a/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/output-name-conflict.pp b/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/output-name-conflict.pp new file mode 100644 index 00000000..4e012a2c --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/output-name-conflict.pp @@ -0,0 +1,7 @@ +config cidrBlock string { + default = "Test config variable" +} + +output cidrBlock { + value = cidrBlock +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/yaml/output-name-conflict.yaml b/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/yaml/output-name-conflict.yaml new file mode 100644 index 00000000..6acc8a5f --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/output-name-conflict-pp/yaml/output-name-conflict.yaml @@ -0,0 +1,6 @@ +configuration: + cidrBlock: + type: string + default: Test config variable +outputs: + cidrBlock: ${cidrBlock} diff --git a/pkg/pulumiyaml/testing/test/testdata/python-reserved-pp/python-reserved.pp b/pkg/pulumiyaml/testing/test/testdata/python-reserved-pp/python-reserved.pp new file mode 100644 index 00000000..ce440b64 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/python-reserved-pp/python-reserved.pp @@ -0,0 +1,7 @@ +resource assert "lambda:lambda:Lambda" { + lambda = "dns" +} + +output global { + value = assert.lambda +} diff --git a/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/regress-11176.pp b/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/regress-11176.pp new file mode 100644 index 00000000..be80074e --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/regress-11176.pp @@ -0,0 +1,4 @@ +resource cluster "aws:ecs/cluster:Cluster" {} +resource nginx "awsx:ecs:FargateService" { + cluster = cluster.arn +} diff --git a/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/yaml/regress-11176.yaml b/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/yaml/regress-11176.yaml new file mode 100644 index 00000000..0814c375 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/regress-11176-pp/yaml/regress-11176.yaml @@ -0,0 +1,7 @@ +resources: + cluster: + type: aws:ecs:Cluster + nginx: + type: awsx:ecs:FargateService + properties: + cluster: ${cluster.arn} diff --git a/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/retain-on-delete.pp b/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/retain-on-delete.pp new file mode 100644 index 00000000..076e4bf8 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/retain-on-delete.pp @@ -0,0 +1,5 @@ +resource foo "random:index/randomPet:RandomPet" { + options { + retainOnDelete = true + } +} diff --git a/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/yaml/retain-on-delete.yaml b/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/yaml/retain-on-delete.yaml new file mode 100644 index 00000000..ed042a02 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/retain-on-delete-pp/yaml/retain-on-delete.yaml @@ -0,0 +1,4 @@ +resources: + foo: + type: random:RandomPet + options: {} diff --git a/pkg/pulumiyaml/testing/test/testdata/simple-range-pp/simple-range.pp b/pkg/pulumiyaml/testing/test/testdata/simple-range-pp/simple-range.pp index b28985d2..cb88b96c 100644 --- a/pkg/pulumiyaml/testing/test/testdata/simple-range-pp/simple-range.pp +++ b/pkg/pulumiyaml/testing/test/testdata/simple-range-pp/simple-range.pp @@ -1,8 +1,12 @@ -resource bucket "aws:s3:Bucket" { +resource numbers "random:index/randomInteger:RandomInteger" { options { - range = 10 + range = 2 } - website = { - indexDocument = "index-${range.value}.html" - } -} \ No newline at end of file + + min = 1 + max = range.value + seed = "seed${range.value}" +} + +output first { value = numbers[0].id } +output second { value = numbers[1].id } diff --git a/pkg/pulumiyaml/testing/test/testdata/simple-splat-pp/simple-splat.pp b/pkg/pulumiyaml/testing/test/testdata/simple-splat-pp/simple-splat.pp new file mode 100644 index 00000000..197dc8d3 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/simple-splat-pp/simple-splat.pp @@ -0,0 +1,5 @@ +allKeys = invoke("splat:index:getSshKeys", {}) + +resource "main" "splat:index:Server" { + sshKeys = allKeys.sshKeys[*].name +} diff --git a/pkg/pulumiyaml/testing/test/testdata/simplified-invokes-pp/simplified-invokes.pp b/pkg/pulumiyaml/testing/test/testdata/simplified-invokes-pp/simplified-invokes.pp new file mode 100644 index 00000000..cd5a60cf --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/simplified-invokes-pp/simplified-invokes.pp @@ -0,0 +1,23 @@ +everyArg = invoke("std:index:AbsMultiArgs", { + a: 10 + b: 20 + c: 30 +}) + +onlyRequiredArgs = invoke("std:index:AbsMultiArgs", { + a: 10 +}) + +optionalArgs = invoke("std:index:AbsMultiArgs", { + a: 10 + c: 30 +}) + +nestedUse = invoke("std:index:AbsMultiArgs", { + a: everyArg + b: invoke("std:index:AbsMultiArgs", { a: 42 }) +}) + +output result { + value = nestedUse +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/single-or-none-pp/single-or-none.pp b/pkg/pulumiyaml/testing/test/testdata/single-or-none-pp/single-or-none.pp new file mode 100644 index 00000000..bb58bdfc --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/single-or-none-pp/single-or-none.pp @@ -0,0 +1,3 @@ +output result { + value = singleOrNone([ 1 ]) +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/snowflake-python-12998-pp/snowflake-python-12998.pp b/pkg/pulumiyaml/testing/test/testdata/snowflake-python-12998-pp/snowflake-python-12998.pp new file mode 100644 index 00000000..d9a11084 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/snowflake-python-12998-pp/snowflake-python-12998.pp @@ -0,0 +1,7 @@ +resource tableAssociation "snowflake:index/tagAssociation:TagAssociation" { + objectIdentifiers =[{ + name = test.name, + database = snowflake_database.value.name, + schema = snowflake_schema.value.name + }] +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/throw-not-implemented-pp/throw-not-implemented.pp b/pkg/pulumiyaml/testing/test/testdata/throw-not-implemented-pp/throw-not-implemented.pp new file mode 100644 index 00000000..192f7737 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/throw-not-implemented-pp/throw-not-implemented.pp @@ -0,0 +1,3 @@ +output result { + value = notImplemented("expression here is not implemented yet") +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/unknown-invoke.pp b/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/unknown-invoke.pp new file mode 100644 index 00000000..61eb631a --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/unknown-invoke.pp @@ -0,0 +1,9 @@ +data = invoke("unknown:index:getData", { + input = "hello" +}) + +values = invoke("unknown:eks:moduleValues", {}) + +output "content" { + value = data.content +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/yaml/unknown-invoke.yaml b/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/yaml/unknown-invoke.yaml new file mode 100644 index 00000000..353d526b --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/unknown-invoke-pp/yaml/unknown-invoke.yaml @@ -0,0 +1,12 @@ +variables: + data: + fn::invoke: + Function: unknown:getData + Arguments: + input: hello + values: + fn::invoke: + Function: unknown:eks:moduleValues + Arguments: {} +outputs: + content: ${data.content} diff --git a/pkg/pulumiyaml/testing/test/testdata/unknown-resource-pp/unknown-resource.pp b/pkg/pulumiyaml/testing/test/testdata/unknown-resource-pp/unknown-resource.pp new file mode 100644 index 00000000..78ac4227 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/unknown-resource-pp/unknown-resource.pp @@ -0,0 +1,21 @@ +resource provider "pulumi:providers:unknown" { } + +resource main "unknown:index:main" { + first = "hello" + second = { + foo = "bar" + } +} + +resource fromModule "unknown:eks:example" { + options { range = 10 } + associatedMain = main.id +} + +output "mainId" { + value = main.id +} + +output "values" { + value = fromModule.values.first +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/using-dashes.pp b/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/using-dashes.pp new file mode 100644 index 00000000..27413673 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/using-dashes.pp @@ -0,0 +1,3 @@ +resource "main" "using-dashes:index:Dash" { + stack = "dev" +} \ No newline at end of file diff --git a/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/yaml/using-dashes.yaml b/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/yaml/using-dashes.yaml new file mode 100644 index 00000000..b0f95b06 --- /dev/null +++ b/pkg/pulumiyaml/testing/test/testdata/using-dashes-pp/yaml/using-dashes.yaml @@ -0,0 +1,5 @@ +resources: + main: + type: using-dashes:Dash + properties: + stack: dev diff --git a/scripts/get_schemas.sh b/scripts/get_schemas.sh index d1c3db4d..b5055f15 100755 --- a/scripts/get_schemas.sh +++ b/scripts/get_schemas.sh @@ -27,6 +27,10 @@ schemas=( "google-native@0.18.2" $(pulumi_schema synthetic 1.0.0) $(pulumi_schema other 0.1.0) + $(pulumi_schema splat 1.0.0) + $(pulumi_schema std 1.0.0) # there's no pulumi-std 1.0.0 + $(pulumi_schema snowflake 0.66.1) # not a real pulumi-snowflake schema + $(pulumi_schema using-dashes 1.0.0) ) for s in "${schemas[@]}"; do