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

efsVolumeConfiguration is unsupported in ecs.CfnTaskDefinition #6918

Closed
mscharley opened this issue Mar 21, 2020 · 7 comments · Fixed by #8467
Closed

efsVolumeConfiguration is unsupported in ecs.CfnTaskDefinition #6918

mscharley opened this issue Mar 21, 2020 · 7 comments · Fixed by #8467
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2

Comments

@mscharley
Copy link

I'm trying to use the newish EFS mounts in an EC2 ECS cluster and the resources are refusing to include the extra parameters even if I try to use the raw resources.

https://aws.amazon.com/about-aws/whats-new/2020/01/amazon-ecs-preview-support-for-efs-file-systems-now-available/

Reproduction Steps

import * as ec2 from "@aws-cdk/aws-ec2";
import * as ecs from "@aws-cdk/aws-ecs";
import * as efs from "@aws-cdk/aws-efs";
import * as elbv2 from "@aws-cdk/aws-elasticloadbalancingv2";
import * as logs from "@aws-cdk/aws-logs";
import * as cdk from "@aws-cdk/core";

export interface WebserverProps {
    filesystem: efs.IEfsFileSystem;
}

export class Webserver extends cdk.Construct {
    public constructor(scope: cdk.Construct, id: string, props: WebserverProps) {
        super(scope, id);
        
        // https://github.com/aws/containers-roadmap/issues/53 - EFS + Fargate
        const taskDefinition = new ecs.TaskDefinition(this, "TaskDefinition", {
            compatibility: ecs.Compatibility.EC2,
        });

        // Patch in the EFS support.
        const rawTask = taskDefinition.node.findChild("Resource") as ecs.CfnTaskDefinition;
        rawTask.volumes = [
            {
                name: "invision",
                efsVolumeConfiguration: {
                    fileSystemId: props.filesystem.fileSystemId,
                    rootDirectory: "/",
                },
            } as ecs.CfnTaskDefinition.VolumeProperty,
        ];
    }
}

Error Log

None, the resource just refuses to include the efsVolumeConfiguration options.

Environment

  • CLI Version : 1.30.0
  • Framework Version: 1.30.0
  • OS : Windows 10
  • Language : Typescript

Other


This is 🐛 Bug Report

@mscharley mscharley added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 21, 2020
@SomayaB SomayaB added the @aws-cdk/aws-efs Related to Amazon Elastic File System label Mar 25, 2020
@SomayaB SomayaB added @aws-cdk/aws-ecs Related to Amazon Elastic Container and removed @aws-cdk/aws-efs Related to Amazon Elastic File System labels Mar 25, 2020
@SomayaB SomayaB assigned uttarasridhar and unassigned rix0rrr Mar 25, 2020
@SoManyHs SoManyHs added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. feature-request A feature should be added or improved. effort/medium Medium work item – several days of effort p2 and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 6, 2020
@pahud
Copy link
Contributor

pahud commented Apr 9, 2020

I am afraid efsVolumeConfiguration is not supported in cloudformation yet.

Pending on this issue aws/containers-roadmap#825

@mscharley
Copy link
Author

Ah, I guess that would explain why it's not in CDK yet either then. I followed a few links from that one and saw it's recently been released to EC2 ECS and Fargate as general release now though so good to see some progress on this. Thanks for the update.

@machielg
Copy link

Anyone found a good workaround for this? I'm afraid a custom resource might involve redoing the whole ECS creation using the AWS API.

@mscharley
Copy link
Author

For now I'm using EC2 ECS, mounting the EFS partitions manually on boot via user data and using bind mounts in the task description.

@Fluro
Copy link

Fluro commented May 5, 2020

If you're using EC2 ECS you can just get docker to mount your File System:

  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Volumes:
        - Name: jenkins_home
          DockerVolumeConfiguration:
            Driver: local
            DriverOpts:
              type: nfs
              device: !Sub "${ClusterFileSystem}.efs.${AWS::Region}.amazonaws.com:/"
              o: !Sub "addr=${ClusterFileSystem}.efs.${AWS::Region}.amazonaws.com,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2"
            Labels:
              foo: bar
            Scope: shared
            # Autoprovision: true
      Family: jenkins-frontend
      ContainerDefinitions:
        - Name: jenkins-frontend
          Essential: true
          Image: jenkins/jenkins:lts
          MemoryReservation: 512
          Environment:
            - Name: JENKINS_OPTS
              Value: --prefix=/jenkins
          PortMappings:
            - ContainerPort: 8080
          MountPoints:
            - containerPath: /var/jenkins_home/
              sourceVolume: jenkins_home

@michaelmoussa
Copy link
Contributor

I managed to devise a fairly consistent workaround to handle EFS volume configurations (as well as EFS access points and filesystem policies) while I wait for CFN+CDK support.

Full repo with the examples is https://github.com/aws-samples/amazon-efs-integrations/ if you want to give it a try separately before trying this workaround on your real code.

Basically, I let the ApplicationLoadBalanced(Ec2|Fargate)Service construct from ECS Patterns create the initial task definition, then I use an AwsCustomResource construct to execute a registerTaskDefinition call against that same task definition and pass it the actual task definition configuration I need in order to configure my EFS volume mounts. This ends up creating a new revision, which I then use a CDK escape hatch to apply to the ECS service. This does result in a longer first-time deployment (since CDK will wait for the ECS service to stabilize before goes and changes everything), but subsequent deployments are fine.

The reason this all works is because, while there's no CFN support yet for EFS volume configurations in ECS, there is support for it in the SDK, which does not reject a task definition using efsVolumeConfiguration like the CDK TaskDefinition derivatives would.

I like this approach over the other workarounds I've seen because (a) it lets me do everything in CDK with no additional commands or manual console instructions required, (b) it lets me take advantage of all the conveniences that the ApplicationLoadBalanced(Ec2|Fargate)Service constructs provide, and (c) once CDK support for these capabilities is enabled, it should make refactoring very easy since all of the task definition configuration is already there alongside where I initially create the service.

Hope this helps somebody!

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jun 11, 2020
@mergify mergify bot closed this as completed in #8467 Aug 18, 2020
mergify bot pushed a commit that referenced this issue Aug 18, 2020
The PR is adding EfsVolumeConfiguration options to TaskDefinition as described on https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html#specify-efs-config

Full documentation is missing from CloudFormation documentation and is therefore not referenced.
While the unit test is passing, I haven't add the possibility to test this feature in practice.

fixes #6918
closes #8448

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
misterjoshua pushed a commit to misterjoshua/aws-cdk that referenced this issue Aug 19, 2020
The PR is adding EfsVolumeConfiguration options to TaskDefinition as described on https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html#specify-efs-config

Full documentation is missing from CloudFormation documentation and is therefore not referenced.
While the unit test is passing, I haven't add the possibility to test this feature in practice.

fixes aws#6918
closes aws#8448

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@airmonitor
Copy link

airmonitor commented Nov 18, 2020

Now you can add mount point much easier:

task = FargateTaskDefinition(self, "Task",...)

container = task.add_container("container", ...)

container_volume_mount_point = ecs.MountPoint(
            read_only=False,
            container_path="/bitnami/wordpress",
            source_volume=efs_volume.name
        )
container.add_mount_points(container_volume_mount_point)

mergify bot pushed a commit that referenced this issue Nov 14, 2022
…lambda-layer-awscli (#22905)

Bumps [awscli](https://github.com/aws/aws-cli) from 1.27.3 to 1.27.8.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/aws/aws-cli/blob/develop/CHANGELOG.rst">awscli's changelog</a>.</em></p>
<blockquote>
<h1>1.27.8</h1>
<ul>
<li>api-change:<code>glue</code>: Added links related to enabling job bookmarks.</li>
<li>api-change:<code>iot</code>: This release add new api listRelatedResourcesForAuditFinding and new member type IssuerCertificates for Iot device device defender Audit.</li>
<li>api-change:<code>license-manager</code>: AWS License Manager now supports onboarded Management Accounts or Delegated Admins to view granted licenses aggregated from all accounts in the organization.</li>
<li>api-change:<code>marketplace-catalog</code>: Added three new APIs to support tagging and tag-based authorization: TagResource, UntagResource, and ListTagsForResource. Added optional parameters to the StartChangeSet API to support tagging a resource while making a request to create it.</li>
<li>api-change:<code>rekognition</code>: Adding support for ImageProperties feature to detect dominant colors and image brightness, sharpness, and contrast, inclusion and exclusion filters for labels and label categories, new fields to the API response, &quot;aliases&quot; and &quot;categories&quot;</li>
<li>api-change:<code>securityhub</code>: Documentation updates for Security Hub</li>
<li>api-change:<code>ssm-incidents</code>: RelatedItems now have an ID field which can be used for referencing them else where. Introducing event references in TimelineEvent API and increasing maximum length of &quot;eventData&quot; to 12K characters.</li>
</ul>
<h1>1.27.7</h1>
<ul>
<li>api-change:<code>autoscaling</code>: This release adds a new price capacity optimized allocation strategy for Spot Instances to help customers optimize provisioning of Spot Instances via EC2 Auto Scaling, EC2 Fleet, and Spot Fleet. It allocates Spot Instances based on both spare capacity availability and Spot Instance price.</li>
<li>api-change:<code>ec2</code>: This release adds a new price capacity optimized allocation strategy for Spot Instances to help customers optimize provisioning of Spot Instances via EC2 Auto Scaling, EC2 Fleet, and Spot Fleet. It allocates Spot Instances based on both spare capacity availability and Spot Instance price.</li>
<li>api-change:<code>ecs</code>: This release adds support for task scale-in protection with updateTaskProtection and getTaskProtection APIs. UpdateTaskProtection API can be used to protect a service managed task from being terminated by scale-in events and getTaskProtection API to get the scale-in protection status of a task.</li>
<li>api-change:<code>es</code>: Amazon OpenSearch Service now offers managed VPC endpoints to connect to your Amazon OpenSearch Service VPC-enabled domain in a Virtual Private Cloud (VPC). This feature allows you to privately access OpenSearch Service domain without using public IPs or requiring traffic to traverse the Internet.</li>
<li>api-change:<code>resource-explorer-2</code>: Text only updates to some Resource Explorer descriptions.</li>
<li>api-change:<code>scheduler</code>: AWS introduces the new Amazon EventBridge Scheduler. EventBridge Scheduler is a serverless scheduler that allows you to create, run, and manage tasks from one central, managed service.</li>
</ul>
<h1>1.27.6</h1>
<ul>
<li>enhancement:docs: Fixes <code>[#6918](aws/aws-cli#6918) &lt;https://github.com/aws/aws-cli/issues/6918&gt;</code>__ and <code>[#7400](aws/aws-cli#7400) &lt;https://github.com/aws/aws-cli/issues/7400&gt;</code>__. The CLI falls back on mandoc if groff isn't available.</li>
<li>api-change:<code>connect</code>: This release adds new fields SignInUrl, UserArn, and UserId to GetFederationToken response payload.</li>
<li>api-change:<code>connectcases</code>: This release adds the ability to disable templates through the UpdateTemplate API. Disabling templates prevents customers from creating cases using the template. For more information see <a href="https://docs.aws.amazon.com/cases/latest/APIReference/Welcome.html">https://docs.aws.amazon.com/cases/latest/APIReference/Welcome.html</a></li>
<li>api-change:<code>ec2</code>: Amazon EC2 Trn1 instances, powered by AWS Trainium chips, are purpose built for high-performance deep learning training. u-24tb1.112xlarge and u-18tb1.112xlarge High Memory instances are purpose-built to run large in-memory databases.</li>
<li>api-change:<code>groundstation</code>: This release adds the preview of customer-provided ephemeris support for AWS Ground Station, allowing space vehicle owners to provide their own position and trajectory information for a satellite.</li>
<li>api-change:<code>mediapackage-vod</code>: This release adds &quot;IncludeIframeOnlyStream&quot; for Dash endpoints.</li>
<li>api-change:<code>endpoint-rules</code>: Update endpoint-rules command to latest version</li>
</ul>
<h1>1.27.5</h1>
<ul>
<li>api-change:<code>acm</code>: Support added for requesting elliptic curve certificate key algorithm types P-256 (EC_prime256v1) and P-384 (EC_secp384r1).</li>
<li>api-change:<code>billingconductor</code>: This release adds the Recurring Custom Line Item feature along with a new API ListCustomLineItemVersions.</li>
<li>api-change:<code>ec2</code>: This release enables sharing of EC2 Placement Groups across accounts and within AWS Organizations using Resource Access Manager</li>
<li>api-change:<code>fms</code>: AWS Firewall Manager now supports importing existing AWS Network Firewall firewalls into Firewall Manager policies.</li>
<li>api-change:<code>lightsail</code>: This release adds support for Amazon Lightsail to automate the delegation of domains registered through Amazon Route 53 to Lightsail DNS management and to automate record creation for DNS validation of Lightsail SSL/TLS certificates.</li>
<li>api-change:<code>opensearch</code>: Amazon OpenSearch Service now offers managed VPC endpoints to connect to your Amazon OpenSearch Service VPC-enabled domain in a Virtual Private Cloud (VPC). This feature allows you to privately access OpenSearch Service domain without using public IPs or requiring traffic to traverse the Internet.</li>
<li>api-change:<code>polly</code>: Amazon Polly adds new voices: Elin (sv-SE), Ida (nb-NO), Laura (nl-NL) and Suvi (fi-FI). They are available as neural voices only.</li>
<li>api-change:<code>resource-explorer-2</code>: This is the initial SDK release for AWS Resource Explorer. AWS Resource Explorer lets your users search for and discover your AWS resources across the AWS Regions in your account.</li>
<li>api-change:<code>route53</code>: Amazon Route 53 now supports the Europe (Zurich) Region (eu-central-2) for latency records, geoproximity records, and private DNS for Amazon VPCs in that region.</li>
<li>api-change:<code>endpoint-rules</code>: Update endpoint-rules command to latest version</li>
</ul>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/aws/aws-cli/commit/92715954bd3e461d7ec0e623b8e4f98d3351eee8"><code>9271595</code></a> Merge branch 'release-1.27.8'</li>
<li><a href="https://github.com/aws/aws-cli/commit/fc6037f534ed1209975a19a08c328996bf856695"><code>fc6037f</code></a> Bumping version to 1.27.8</li>
<li><a href="https://github.com/aws/aws-cli/commit/4ba58aa74d31b2b3e7657afc729c739098c13d2c"><code>4ba58aa</code></a> Update changelog based on model updates</li>
<li><a href="https://github.com/aws/aws-cli/commit/7d7d7691276894fa5b4b86363b7f235c52b4a140"><code>7d7d769</code></a> Fix typo (<a href="https://github-redirect.dependabot.com/aws/aws-cli/issues/7427">#7427</a>)</li>
<li><a href="https://github.com/aws/aws-cli/commit/2aabb67d068e02d3de69f7f004daf538324affe4"><code>2aabb67</code></a> Merge branch 'release-1.27.7'</li>
<li><a href="https://github.com/aws/aws-cli/commit/9e9de3cb7b96d63f36e30503bc0d0de52e07399e"><code>9e9de3c</code></a> Merge branch 'release-1.27.7' into develop</li>
<li><a href="https://github.com/aws/aws-cli/commit/2ee7606efad8df945b59c663baf7639e72af7b83"><code>2ee7606</code></a> Bumping version to 1.27.7</li>
<li><a href="https://github.com/aws/aws-cli/commit/35f1b7776b63060b1c05860f60f03a12aaed8487"><code>35f1b77</code></a> Update changelog based on model updates</li>
<li><a href="https://github.com/aws/aws-cli/commit/f3f5f705c5a305d7d7a91c91aa12a845c661ee82"><code>f3f5f70</code></a> Merge branch 'release-1.27.6'</li>
<li><a href="https://github.com/aws/aws-cli/commit/ef2071eb83a780e12d621baf875b04ff125a6dbc"><code>ef2071e</code></a> Merge branch 'release-1.27.6' into develop</li>
<li>Additional commits viewable in <a href="https://github.com/aws/aws-cli/compare/1.27.3...1.27.8">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=awscli&package-manager=pip&previous-version=1.27.3&new-version=1.27.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants