Skip to content

Latest commit

 

History

History

ecs-anywhere

ECS Anywhere

How To Test

First clone the repository

git clone https://github.com/Michae1CC/aws-cdk-examples

and change directory into the sqs-sns-fanout folder.

cd ecs-anywhere

Run

npm install

to install the required packages to create our Cloudformation template and then

cdk bootstrap && cdk deploy

Make sure you have docker running during this step.


Tip: If you're podman, or some other image building client, you can specify the alternative client for cdk by setting the environment variable CDK_DOCKER to the name of the image building command. In the case for podman

export CDK_DOCKER=podman

During the setup you will need to set up the ecs-agent on the on-prem device for the ecs cluster created within cdk, see: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-registration.html. Note the device you are installing the agent should not have any existing IAM credentials setup on it.

Once the deploy has finished, the SQS URL and dynamodb table name should be displayed as outputs.

EcsAnywhereStack.sqsQueueUrl = <SQS-URL>
EcsAnywhereStack.tableName = <DYNAMODB-TABLE-NAME>

A new message to the created SQS can be made using the following aws cli command

aws sqs send-message --queue-url <SQS-URL> --message-body '{"url":"https://example.com"}'

After a minute, the message should be processed by the task running on the external task and entered into the dynamodb table.

aws dynamodb scan --table-name <DYNAMODB-TABLE-NAME>
{
    "Items": [
        {
            "id": {
                "S": "https://example.com"
            }
        }
    ],
    "Count": 1,
    "ScannedCount": 1,
    "ConsumedCapacity": null
}

Clean Up

First register the instance/s used in the ecs service, see: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-deregistration.html.

After run

cdk destroy

Resources