I have a specific script that host some important configurations. The script basically generates a record structure on my documentDB.
This particular script is hosted on an independent repository on Github. I want to create a task when the code is merged into master using github action. This task should call the script that's defined on the Dockerfile.
My current github action looks like this
on:
pull_request:
branches:
- master
name: Deploy to Amazon ECS
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
ENVIRONMENT: ${{ github.head_ref == 'master' && 'prod' || github.ref_name == 'master' && 'prod' || github.head_ref || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AVERO_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AVERO_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AVERO_AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: module
IMAGE_TAG: ${{ github.sha }}
ENVIRONMENT: ${{ secrets.ENVIRONMENT || 'test' }}
run: |
docker build --build-arg --build-arg ENVIRONMENT="${ENVIRONMENT}" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Replace task-definition variables with data from the env
uses: microsoft/variable-substitution@v1
with:
files: .aws/task-definition.json
env:
containerDefinitions.0.name: ${{ env.ENVIRONMENT }}-container
containerDefinitions.0.environment.0.value: ${{ env.ENVIRONMENT == 'prod' && 'production' || env.ENVIRONMENT }}
containerDefinitions.0.secrets.0.valueFrom: /system/${{ env.ENVIRONMENT }}/some-value
containerDefinitions.0.secrets.1.valueFrom: /system/${{ env.ENVIRONMENT }}/some-value
containerDefinitions.0.logConfiguration.options.awslogs-group: /system/${{ env.ENVIRONMENT }}/module
containerDefinitions.0.logConfiguration.options.awslogs-region: ${{ secrets.AVERO_AWS_DEFAULT_REGION }}
family: ${{ env.ENVIRONMENT }}-task-definition
taskRoleArn: arn:aws:iam::${{secrets.AVERO_AWS_ACCOUNT_NUMBER}}:role/system/${{ env.ENVIRONMENT }}/module/${{ env.ENVIRONMENT }}-system-role
executionRoleArn: arn:aws:iam::${{secrets.AVERO_AWS_ACCOUNT_NUMBER}}:role/system/${{ env.ENVIRONMENT }}/module/${{ env.ENVIRONMENT }}-system-role
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: .aws/task-definition.json
container-name: ${{ env.ENVIRONMENT }}-container
image: ${{ steps.build-image.outputs.image }}
- name: Run my ECS task
uses: zamarawka/aws-run-fargate-task@v1
with:
task_name: ${{ env.ENVIRONMENT }}-task-definition
cluster: ${{ env.ENVIRONMENT }}-cluster
wait: true
When running the workflow, I have an exception on the last step. The error looks like follows:
Run fargate task Fetch network settings InvalidParameterValue: The filter 'null' is invalid
Some considerations:
- I do not want to create a fargate service, because I do not have any need to keep this script running after it finishes.
- I cannot use Lambda because the process could take +15min
I realized that when running a task from the web interface the network configuration is required, that's something I didn't really send on the task-definition because there is no parameter for that.
Do you have any idea how can I achieve this?