A low cost Graviton AWS Fargate task that has a durable storage volume mounted at /srv
TypeScriptBelow is a Pulumi program to create a low-cost AWS Fargate task using Graviton processors, which includes a durable storage volume mounted at
/srv
.import * as awsx from "@pulumi/awsx"; // Create an ECS Fargate cluster. const cluster = new awsx.ecs.Cluster("my-cluster"); // Define the volume to mount. const volume: awsx.ecs.Volume = { name: "my-volume", efsVolumeConfiguration: { fileSystemId: "fs-xxxxxxxx", // Replace with the actual file system ID of your EFS storage }, }; // Create a Fargate service with a task that has a durable EFS volume mounted. const service = new awsx.ecs.FargateService("my-service", { cluster, taskDefinitionArgs: { containers: { my_container: { image: "nginx", // Replace with your preferred container image // Set the CPU and memory based on the required Graviton2 processor configuration. cpu: 256, // Quarter vCPU memory: 512, // 0.5GB memory portMappings: [{ containerPort: 80 }], mountPoints: [{ containerPath: "/srv", sourceVolume: volume.name }], environment: [ // Environment variables required by the container can be listed here. ], }, }, volumes: [volume], // Specify the platform version, for Fargate use 'LATEST' runtimePlatform: { cpuArchitecture: 'ARM64', // To use Graviton processors }, }, // Desired count specifies the number of tasks to run. desiredCount: 1, // If you need to specify an IAM role for the Fargate execution role, you can do so here. }); // Export the URL of the service. export const url = service.endpoint.apply(ep => `http://${ep.hostname}`);
Make sure to replace
fs-xxxxxxxx
with the actual EFS file system ID you wish to use and define the proper Docker image for your container. Thecpu
andmemory
configuration should align with your Graviton2 processor requirements and your application needs.The mounted volume configuration assumes that you have an existing EFS file system. If you don't have one, you'll need to provision it in AWS and provide its file system ID to the Pulumi program.