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

resource/aws_ecs_task_definition: Support task scoped docker volume configurations #5907

Merged
merged 6 commits into from
Oct 3, 2018

Conversation

camdenfullmer
Copy link
Contributor

@camdenfullmer camdenfullmer commented Sep 17, 2018

Recently support was added for Docker volume configurations for ECS task definitions: #5727

Unfortunately, if you want a task scoped docker volume configuration this implementation doesn't work resulting in the following error:

Error: Error applying plan:

1 error(s) occurred:

* aws_ecs_task_definition.service: 1 error(s) occurred:

* aws_ecs_task_definition.service: ClientException: When 'scope' parameter is 'task', 'autoprovision' must either not be specified or set to 'True'.
	status code: 400, request id: <REQUEST_ID>

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

With the following configuraiton:

volume {
    name      = "scratch"
    docker_volume_configuration {
        scope         = "task"
        driver        = "local"
    }
}

It seems that not specifying a value results in autoprovision being set to false. Setting autoprovison to true results in an error when the ECS agent tries to run the task.

AWS documentation states that autoprovision is only used for shared scope: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-volumes.html

Changes proposed in this pull request:

  • Set Autoprovision to nil when using a task scoped docker volume and autoprovision is set to false.

Questions:

  • I tried removing the Default value of false, but false was still picked up as the value. Is there a way to check for no value and set it to nil instead?

@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Sep 17, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. labels Sep 18, 2018
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/S Managed by automation to categorize the size of a PR. labels Sep 28, 2018
@FernandoMiguel
Copy link
Contributor

also being affected by this. couldnt find a workaround for false

@camdenfullmer
Copy link
Contributor Author

@bflad Is there anything else I need to add to this PR to get it merged into a release?

@bflad
Copy link
Contributor

bflad commented Oct 2, 2018

@camdenfullmer are you able to implement a separate acceptance test instead of modifying the existing one? Duplicating (with minor adjustments) the existing test and test configuration is perfectly fine. We should perform regression testing on both scenarios. 👍

@camdenfullmer
Copy link
Contributor Author

camdenfullmer commented Oct 2, 2018

Yep, I can do that 👍

@bflad bflad added this to the v1.39.0 milestone Oct 2, 2018
@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Oct 3, 2018
@camdenfullmer
Copy link
Contributor Author

@bflad Added a new test instead of modifying the existing one.

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks great, @camdenfullmer! 🚀

--- PASS: TestAccAWSEcsTaskDefinition_withScratchVolume (4.72s)
--- PASS: TestAccAWSEcsTaskDefinition_withTaskScopedDockerVolume (5.00s)
--- PASS: TestAccAWSEcsTaskDefinition_arrays (5.09s)
--- PASS: TestAccAWSEcsTaskDefinition_withDockerVolume (5.09s)
--- PASS: TestAccAWSEcsTaskDefinition_constraint (5.12s)
--- PASS: TestAccAWSEcsTaskDefinition_withDockerVolumeMinimalConfig (5.12s)
--- PASS: TestAccAWSEcsTaskDefinition_ExecutionRole (12.62s)
--- PASS: TestAccAWSEcsTaskDefinition_basic (13.06s)
--- PASS: TestAccAWSEcsTaskDefinition_changeVolumesForcesNewResource (13.16s)
--- PASS: TestAccAWSEcsTaskDefinition_Inactive (13.76s)
--- PASS: TestAccAWSEcsTaskDefinition_Fargate (17.93s)
--- PASS: TestAccAWSEcsTaskDefinition_withNetworkMode (20.57s)
--- PASS: TestAccAWSEcsTaskDefinition_withTaskRoleArn (21.22s)
--- PASS: TestAccAWSEcsTaskDefinition_withEcsService (63.25s)

@bflad bflad merged commit 4fb4bef into hashicorp:master Oct 3, 2018
bflad added a commit that referenced this pull request Oct 3, 2018
@ghost
Copy link

ghost commented Oct 3, 2018

This has been released in version 1.39.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "aws" {
	version = "~> 1.39.0"
}
# ... other configuration ...

@FernandoMiguel
Copy link
Contributor

Thank you both

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants