I need to do environment variable substitution from a value from a SSM secret (secrets section in manifest). But escaping doesn't work as the doco mentioned.
variables:
TEST1: "https://\\${DATABASE_SERVER}:5000/ReportServer?"
TEST2: https://\${DATABASE_SERVER}:5000/ReportServer?
secrets: # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
DATABASE_SERVER: /database/server
I am getting the following error:
✘ interpolate environment variables for fisherassist-api manifest: environment variable "DATABASE_SERVER" is not defined
Firstly, this feature was released in copilot CLI v1.33.0 and I was using a older version. Got support from a ever so helpful mate from copilot gitter community 🙏🏼
Secondly, composing Run time variables from other variables is not possible with Copilot at the moment. A similar feature request is there for this.
There are 2 workarounds to achieve this.
This is a bit complicated workaround is possibly modifying the ENTRYPOINT
#!/bin/sh
export TEST1="https://${DATABASE_SERVER}:5000/ReportServer?"
export TEST2="https://${DATABASE_SERVER}:5000/ReportServer?"
# Now execute the main process of the container
exec "$@"
# Copy the entrypoint script into the container
COPY entrypoint.sh /entrypoint.sh
# Set the script as the entry point
ENTRYPOINT ["/entrypoint.sh"]
CMD ["your_application_start_command"]
secrets:
DATABASE_SERVER: /database/server
This way the DATABASE_SERVER environment variable can be passed at runtime, and entrypoint.sh will set TEST1 and TEST2 accordingly.