How to make a AppConfig-managed configuration file on S3 available to an ECS service on Fargate?

0

Dear community,

I am trying to create a application with the following properties:

  1. the different components of the app will be shipped in docker containers and are hosted on ECR
  2. each container will have some configuration file hosted on S3 that will be updated dynamically during deployment
  3. the containers will be deployed with ECS on Amazon Fargate as a service

Currently, I am running a minimal version of the app in the following way:

  1. Uploaded an image to ECR that contains the config file due to copying (static config)
FROM eclipse-mosquitto
COPY ./mosquitto.conf /mosquitto/config/mosquitto.conf
  1. Defined a task with only this image and deployed it with ECS on Fargate
  2. Loaded the configuration file into an S3 Bucket
  3. Created a configuration profile on AppConfig

Here I got stuck. In my mind, several question arise:

  • How do I connect the config file in the container to the AppConfig managed file on S3?
  • When a configuration file is updated, can I hook into this process to restart the server inside the container?
  • Is using AppConfig appropriate here? Or would it be easier to restart the container and use a pull command from S3 on container startup to update the file?

I appreciate your help!

Best regards,

1개 답변
1
수락된 답변

AppConfig may not be the best fit for this use case as described: it doesn't deliver configuration files to disk, but instead requires the application to call its API to refresh the configuration. (So you would then update your configuration in AppConfig, deploy it, and your application would, on next refresh*, receive the updated configuration.) Your application would need to be modified to call the AppConfig API instead of loading the configuration off disk. If you're happy reading Python, there's a sample library which you can dig in to to see how you might do it.

However, if you can arrange for a script to run inside your container, you could use the AWS CLI (or another language with an SDK, e.g. Python/boto3) to fetch the configuration from the API and store it in the file for your application, and then notify the application it should reload. An alternative for the last step would be to have the application monitor the modification time of the file, and reload when it is updated. AppConfig itself does not provide any native tooling to do this, I'm afraid, but the documentation has sample AWS CLI commands to get you started.

If neither of those options suit you, then the option you suggest in your third point may be the most straightforward to get you unblocked, although of course you lose some of AppConfig's benefits like validation and automatic rollbacks.

(* subject to your deployment rate)

profile pictureAWS
전문가
James_S
답변함 2년 전
  • Thank you for the quick reply. I will try to modify my setup to work with the suggested "pull"-workflow as I really like the functionality provided by AppConfig. At least I am on the right track now!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠