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

Ignore unchanged attributes #27

Merged
merged 1 commit into from
Feb 11, 2019
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
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ function parseAttributeLine (line: string, lastChange: Changed, errors: Array<Pa
result.new = newObj;
}

if (result.old && result.old.value === result.new.value) {
return;
}

if (forcesNewResource) {
result.forcesNewResource = true;
}
Expand Down
30 changes: 0 additions & 30 deletions test/unit/data/00-terraform-plan.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
},
"forcesNewResource": true
},
"family": {
"old": {
"type": "string",
"value": "sample-app"
},
"new": {
"type": "string",
"value": "sample-app"
}
},
"network_mode": {
"old": {
"type": "string",
Expand All @@ -82,16 +72,6 @@
"new": {
"type": "computed"
}
},
"task_role_arn": {
"old": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
},
"new": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
}
}
},
"newResourceRequired": true
Expand All @@ -112,16 +92,6 @@
},
"forcesNewResource": true
},
"triggers.%": {
"old": {
"type": "string",
"value": "1"
},
"new": {
"type": "string",
"value": "1"
}
},
"triggers.deploy_job_hash": {
"old": {
"type": "string",
Expand Down
30 changes: 0 additions & 30 deletions test/unit/data/01-terraform-plan.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
},
"forcesNewResource": true
},
"family": {
"old": {
"type": "string",
"value": "sample-app"
},
"new": {
"type": "string",
"value": "sample-app"
}
},
"network_mode": {
"old": {
"type": "string",
Expand All @@ -82,16 +72,6 @@
"new": {
"type": "computed"
}
},
"task_role_arn": {
"old": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
},
"new": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
}
}
},
"newResourceRequired": true
Expand All @@ -112,16 +92,6 @@
},
"forcesNewResource": true
},
"triggers.%": {
"old": {
"type": "string",
"value": "1"
},
"new": {
"type": "string",
"value": "1"
}
},
"triggers.deploy_job_hash": {
"old": {
"type": "string",
Expand Down
30 changes: 0 additions & 30 deletions test/unit/data/09-terraform-plan-windows-line-end.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
},
"forcesNewResource": true
},
"family": {
"old": {
"type": "string",
"value": "sample-app"
},
"new": {
"type": "string",
"value": "sample-app"
}
},
"network_mode": {
"old": {
"type": "string",
Expand All @@ -82,16 +72,6 @@
"new": {
"type": "computed"
}
},
"task_role_arn": {
"old": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
},
"new": {
"type": "string",
"value": "arn:aws:iam::123123123123:role/SampleApp"
}
}
},
"newResourceRequired": true
Expand All @@ -112,16 +92,6 @@
},
"forcesNewResource": true
},
"triggers.%": {
"old": {
"type": "string",
"value": "1"
},
"new": {
"type": "string",
"value": "1"
}
},
"triggers.deploy_job_hash": {
"old": {
"type": "string",
Expand Down
25 changes: 25 additions & 0 deletions test/unit/data/14-ignore-unchanged-attributes.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"errors": [],
"changedResources": [
{
"action": "update",
"type": "aws_ecs_service",
"name": "sample_app",
"path": "aws_ecs_service.sample_app",
"changedAttributes": {
"setting.changed": {
"old": {
"type": "string",
"value": "A"
},
"new": {
"type": "string",
"value": "B"
}
}
}
}
],
"changedDataSources": []
}

30 changes: 30 additions & 0 deletions test/unit/data/14-ignore-unchanged-attributes.stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_ecs_service.sample_app: Refreshing state... (ID: arn:aws:ecs:us-east-1:123123123123:service/sample-app)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
-/+ destroy and then create replacement
<= read (data resources)

Terraform will perform the following actions:

~ aws_ecs_service.sample_app
setting.unchanged: "A" => "A"
setting.changed: "A" => "B"



Plan: 0 to add, 1 to change, 0 to destroy.

------------------------------------------------------------------------

This plan was saved to: terraform.plan

To perform exactly these actions, run the following command to apply:
terraform apply "terraform.plan"
4 changes: 4 additions & 0 deletions test/unit/terraform-plan-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ test('should handle modules', async (t) => {
test('should handle no changes', async (t) => {
return runTest('13-no-changes', t);
});

test('should ignore unchanged attributes', async (t) => {
return runTest('14-ignore-unchanged-attributes', t);
});