efsVolumeConfiguration is unsupported in ecs.CfnTaskDefinition
See original GitHub issueI’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.
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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:7 (2 by maintainers)
Top Results From Across the Web
class CfnTaskDefinition (construct) · AWS CDK
The AWS::ECS::TaskDefinition resource describes the container and volume definitions of an Amazon Elastic Container Service (Amazon ECS) task. You can specify ...
Read more >Cloudformation Error - Encountered unsupported property ...
... the property "efsVolumeConfiguration". Currently, the only way to mount EFS volumes on Fargate tasks is via the ECS Console, SDK or CLI....
Read more >awsecs - Go Packages
Amazon ECS Construct Library. This package contains constructs for working with Amazon Elastic Container Service (Amazon ECS).
Read more >aws-cdk efsVolumeConfiguration is unsupported in ecs ... - GitAnswer
aws-cdk efsVolumeConfiguration is unsupported in ecs.CfnTaskDefinition - TypeScript. I'm trying to use the newish EFS mounts in an EC2 ECS cluster and the ......
Read more >aws.ecs.TaskDefinition - Pulumi
Manages a revision of an ECS task definition to be used in aws.ecs.Service . ... efsVolumeConfiguration Changes to this property will trigger replacement....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 anAwsCustomResource
construct to execute aregisterTaskDefinition
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 CDKTaskDefinition
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 © 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!
Now you can add mount point much easier: