Skip to content

Commit

Permalink
Fixes errors and resource cycling issues for aws.batch.JobDefinition (#…
Browse files Browse the repository at this point in the history
…3888)

Recent changes in hashicorp/terraform-provider-aws#37111 introduced a
Diff customizer that leads to errors in the Pulumi version of the
provider due to discrepancies in the order in which Diff customizer
functions are applied between Pulumi and Terraform. This change fixes
the problem by applying the experimental PlanResourceChange flag to the
affected resource.

Fixes #3887

A regression test is included.

See also: pulumi/pulumi-terraform-bridge#1785
  • Loading branch information
t0yv0 authored May 2, 2024
1 parent 86fbe94 commit 450f0d9
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 1 deletion.
24 changes: 24 additions & 0 deletions provider/provider_python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ func TestRegress3196(t *testing.T) {
})
}

func TestRegress3887(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping test in -short mode because it needs cloud credentials")
return
}
test := getPythonBaseOptions(t).
With(integration.ProgramTestOptions{
Quick: true,
SkipRefresh: true,
Dir: filepath.Join("test-programs", "regress-3887"),
EditDirs: []integration.EditDir{
{
Dir: filepath.Join("test-programs", "regress-3887", "step-1"),
Additive: true,
},
{
Dir: filepath.Join("test-programs", "regress-3887", "step-2"),
Additive: true,
},
},
})
integration.ProgramTest(t, &test)
}

func TestRegress1504(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping test in -short mode because it needs cloud credentials")
Expand Down
3 changes: 2 additions & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ func ProviderFromMeta(metaInfo *tfbridge.MetadataInfo) *tfbridge.ProviderInfo {
switch s {
case "aws_ssm_document",
"aws_wafv2_web_acl",
"aws_launch_template":
"aws_launch_template",
"aws_batch_job_definition":
return true
default:
return false
Expand Down
5 changes: 5 additions & 0 deletions provider/test-programs/regress-3887/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: regress-3887
runtime:
name: python
options:
virtualenv: venv
55 changes: 55 additions & 0 deletions provider/test-programs/regress-3887/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition(
"test",
name="my_test_batch_job_definition",
type="container",
container_properties=json.dumps(
{
"command": [
"ls",
"-la",
],
"image": "busybox",
"resourceRequirements": [
{
"type": "VCPU",
"value": "1",
},
{
"type": "MEMORY",
"value": "512",
},
],
"volumes": [
{
"host": {
"sourcePath": "/tmp",
},
"name": "tmp",
}
],
"environment": [
{
"name": "VARNAME",
"value": "VARVAL",
}
],
"mountPoints": [
{
"sourceVolume": "tmp",
"containerPath": "/tmp",
"readOnly": False,
}
],
"ulimits": [
{
"hardLimit": 1024,
"name": "nofile",
"softLimit": 1024,
}
],
}
),
)
2 changes: 2 additions & 0 deletions provider/test-programs/regress-3887/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=6.0.0,<7.0.0
55 changes: 55 additions & 0 deletions provider/test-programs/regress-3887/step-1/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition(
"test",
name="my_test_batch_job_definition",
type="container",
container_properties=json.dumps(
{
"command": [
"ls",
"-la",
],
"image": "busybox",
"resourceRequirements": [
{
"type": "VCPU",
"value": "2",
},
{
"type": "MEMORY",
"value": "512",
},
],
"volumes": [
{
"host": {
"sourcePath": "/tmp",
},
"name": "tmp",
}
],
"environment": [
{
"name": "VARNAME",
"value": "VARVAL",
}
],
"mountPoints": [
{
"sourceVolume": "tmp",
"containerPath": "/tmp",
"readOnly": False,
}
],
"ulimits": [
{
"hardLimit": 1024,
"name": "nofile",
"softLimit": 1024,
}
],
}
),
)
55 changes: 55 additions & 0 deletions provider/test-programs/regress-3887/step-2/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition(
"test",
name="my_test_batch_job_definition",
type="container",
container_properties=json.dumps(
{
"command": [
"ls",
"-la",
],
"image": "busybox",
"resourceRequirements": [
{
"type": "VCPU",
"value": "3",
},
{
"type": "MEMORY",
"value": "512",
},
],
"volumes": [
{
"host": {
"sourcePath": "/tmp",
},
"name": "tmp",
}
],
"environment": [
{
"name": "VARNAME",
"value": "VARVAL",
}
],
"mountPoints": [
{
"sourceVolume": "tmp",
"containerPath": "/tmp",
"readOnly": False,
}
],
"ulimits": [
{
"hardLimit": 1024,
"name": "nofile",
"softLimit": 1024,
}
],
}
),
)

0 comments on commit 450f0d9

Please sign in to comment.