Run Anypoint Flex Gateway in Connected Mode on Customer owned AWS ECS Fargate Cluster
You have to configure required IAM role (executionRoleArn) that grants permissions to the AWS ECS agent to perform actions on your behalf before and during the container's runtime. This Role is used for activities like, Pulling the container image, Pushing container logs to Amazon CloudWatch, Retrieving sensitive data from AWS Secrets Manager or Systems Manager Parameter Store that you've referenced in the task definition. This role is mandatory for all Fargate tasks. Without it, ECS has no permission to set up and manage your container.
We used essential permissions for this basic setup, and based on your needs, you can add more policies as required. First, we create IAM policy that provides access to the registration secret we created in Step 2
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "<arn-value-of-registration-secret-created-in-step2>"
}
]
}
Then,
An ECS task definition is a blueprint for your application within Amazon ECS. It's a text file, typically in JSON format, that specifies how your containers should be run, including which Docker images to use, resource allocation (CPU and memory), networking, and more. The task definition is a blueprint for your application (the "what"), not where it runs (the "where"). The "where" is specified when you either run a standalone task "run-task" (launches one or more standalone tasks until they stop) or create/update an ECS service "create-service" (launches and maintains a long-running application, ensuring a specified number of tasks are always running and healthy) on the created task definition.
In this task definition, we are passing the registration file as secret (environment variable) to flex gateway, so Flex Gateway service reads it and start itself. No need to specify any entrypoint parameters in this case.
Navigate to Amazon ECS > Task definition > click on Create new task definition with JSON
Delete the displayed config and copy paste below task definition. For more info, you can refer to AWS documentation for details on ECS task definition json configuration.
Here, you can specify
Click Create. You should see a Task definition created with name "flex-on-fargate-task-definition"
{
"family": "flex-on-fargate-task-definition",
"networkMode": "awsvpc",
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "2048",
"executionRoleArn": "<arn-of-iam-role-we-created>",
"containerDefinitions": [
{
"name": "flex-gateway",
"image": "mulesoft/flex-gateway:1.10.0",
"portMappings": [
{
"containerPort": 8081,
"hostPort": 8081,
"protocol": "tcp"
}
],
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/flex-gateway",
"awslogs-region": "ap-southeast-1",
"awslogs-stream-prefix": "flex-gw"
}
},
"secrets": [
{
"name": "FLEX_CONFIG",
"valueFrom": "<arn-value-of-registration-secret-created-in-step2>"
}
]
}
]
}
Assuming you have created a ECS cluster (type AWS Fargate) and a VPC with Public Subnets in desired region. Ensure the security group has rules that allow access to Internet (to ensure flex gateway container connects to control plane endpoints documented - link in reference section) and also has rules that accept inbound connection on the port specified in task defintion.
Now, you should see a Service deployment created under your ECS cluster and it takes some time for provisioning.
Once provisioned, you should see the replicas reflecting in Runtime manager under your flex-gateway in Connected/Running State.
Anypoint Flex Gateway on AWS ECS Fargate is successfully provisioned.
005131426

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.