Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ListenerRule panic if no forward parameter is missing in defaultActions #4131

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion provider/cmd/pulumi-resource-aws/bridge-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -232628,4 +232628,4 @@
"aws:workspaces/getWorkspace:getWorkspace": 0
}
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure why this newline started disappearing. I tried adding it back and regenerating the file a couple of times but it kept happening

17 changes: 17 additions & 0 deletions provider/provider_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ func TestParallelLambdaCreation(t *testing.T) {
})
}

func TestRegress4128(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping test in -short mode because it needs cloud credentials")
return
}

test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join("test-programs", "regress-4128"),
SkipRefresh: true,
},
)
// Disable envRegion mangling
test.Config = nil
integration.ProgramTest(t, &test)
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
baseJS := integration.ProgramTestOptions{
Expand Down
2 changes: 2 additions & 0 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ func cleanPlan(t *testing.T, plan map[string]interface{}) map[string]interface{}
if val, exists := plan["manifest"]; exists {
manifest := val.(map[string]interface{})
delete(manifest, "time")
delete(manifest, "version")
delete(manifest, "magic")
}

return plan
Expand Down
4 changes: 3 additions & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,9 @@ func ProviderFromMeta(metaInfo *tfbridge.MetadataInfo) *tfbridge.ProviderInfo {
"aws_wafv2_rule_group",
"aws_batch_job_definition",
"aws_lb_listener",
"aws_alb_listener":
"aws_lb_listener_rule",
"aws_alb_listener",
"aws_alb_listener_rule":
return true
default:
return false
Expand Down
7 changes: 7 additions & 0 deletions provider/test-programs/regress-4128/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: regress-4128
runtime: nodejs
description: A minimal AWS TypeScript Pulumi program
config:
pulumi:tags:
value:
pulumi:template: aws-typescript
99 changes: 99 additions & 0 deletions provider/test-programs/regress-4128/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

const vpc = new awsx.ec2.Vpc("lb-vpc", {
cidrBlock: "10.0.0.0/16",
subnetStrategy: "Auto",
subnetSpecs: [
{
type: "Public",
name: "public-subnet",
},
],
numberOfAvailabilityZones: 3,
natGateways: {
strategy: "None"
}
});

const secGroup = new aws.ec2.SecurityGroup("allowTls", {
description: "Allow TLS inbound traffic and all outbound traffic",
vpcId: vpc.vpcId,
tags: {
Name: "allow_tls",
},
});

const loadbalancer = new aws.lb.LoadBalancer("my-lb", {
loadBalancerType: "application",
securityGroups: [secGroup.id],
subnets: vpc.publicSubnetIds,
internal: true,
});

const targetGroup = new aws.lb.TargetGroup("my-tg", {
port: 80,
protocol: "HTTP",
targetType: "ip",
vpcId: vpc.vpcId,
});

const listener = new aws.lb.Listener("my-listener", {
loadBalancerArn: loadbalancer.arn,
port: 80,
defaultActions: [{
type: "forward",
targetGroupArn: targetGroup.arn,
}],
});

const listenerRule = new aws.lb.ListenerRule("my-listener-rule", {
listenerArn: listener.arn,
priority: 100,
actions: [{
type: "forward",
targetGroupArn: targetGroup.arn,
}],
conditions: [{
pathPattern: {
values: ["/path/*"],
},
}],
});

const alb = new aws.alb.LoadBalancer("my-alb", {
securityGroups: [secGroup.id],
subnets: vpc.publicSubnetIds,
internal: true,
});

const albTg = new aws.alb.TargetGroup("my-alb-tg", {
port: 80,
protocol: "HTTP",
targetType: "ip",
vpcId: vpc.vpcId,
});

const albListener = new aws.lb.Listener("my-alb-listener", {
loadBalancerArn: alb.arn,
port: 80,
defaultActions: [{
type: "forward",
targetGroupArn: albTg.arn,
}],
});

const albRule = new aws.alb.ListenerRule("my-alb-listener-rule", {
listenerArn: albListener.arn,
priority: 100,
actions: [{
type: "forward",
targetGroupArn: albTg.arn,
}],
conditions: [{
pathPattern: {
values: ["/path/*"],
},
}],
});
12 changes: 12 additions & 0 deletions provider/test-programs/regress-4128/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "regress-4128",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18"
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@pulumi/aws": "^6.0.0",
"@pulumi/awsx": "^2.0.2"
}
}
18 changes: 18 additions & 0 deletions provider/test-programs/regress-4128/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}
Loading