Last active
October 18, 2020 18:30
-
-
Save karthikeayan/1c0b42e2857d41fe4b4dc4c6d0a269d2 to your computer and use it in GitHub Desktop.
fargate-deploy-from-jenkins-scheduled-task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat <<EOF >taskdef.json | |
{ | |
"family": "v1-taskDefintion", | |
"containerDefinitions": [ | |
{ | |
"name": "${microservice_name}", | |
"image": "${docker_repo_uri}/${microservice_name}:${tag}”, | |
"portMappings": [ | |
{ | |
"containerPort": ${containerPort}, | |
"hostPort": ${hostPort}, | |
"protocol": "tcp" | |
} | |
], | |
"logConfiguration": { | |
"logDriver": "awslogs", | |
"options": { | |
"awslogs-group": "/ecs/${microservice_name}", | |
"awslogs-region": "${region}", | |
"awslogs-stream-prefix": "ecs" | |
} | |
}, | |
"essential": true, | |
"environment": [ | |
{ | |
"name": "SPRING_PROFILES_ACTIVE", | |
"value": "${SPRING_PROFILE},swagger" | |
}, | |
{ | |
"name": "DEPLOYMENT_VERSION", | |
"value": "${commit_id}" | |
}, | |
{ | |
"name": "SERVER_PORT", | |
"value": "${containerPort}" | |
} | |
] | |
} | |
], | |
"requiresCompatibilities": [ | |
"FARGATE" | |
], | |
"cpu": "1024", | |
"memory": "2048" | |
} | |
EOF | |
aws ecs register-task-definition --family "${microservice_name}" --execution-role-arn ${exec_role_arn} --task-role-arn ${exec_role_arn} --cli-input-json file://taskdef.json --region ${region} --network-mode awsvpc #&> /dev/null | |
aws events put-targets --rule "MyRule1" --targets "Id"="1","Arn"="arn:aws:ecs:us-east-1:123456789012:cluster/default","RoleArn"="arn:aws:iam::123456789012:role/ecsEventsRole","EcsParameters"="{"TaskDefinitionArn"= "arn:aws:ecs:us-east-1:123456789012:task-definition/first-run-task-definition:1","TaskCount"= 1}", "LaunchType"="FARGATE","NetworkConfiguration"="{"awsvpcConfiguration"="{"Subnets"="subnet ID","SecurityGroups"="security group ID","AssignPublicIp"="ENABLED"}"}"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment