0

Right now I have a container for an API that I am looking to push to an AWS Fargate instance that has a connection string for a DB on a privately hosted server. For testing this has been stored in a string in my Golang program, but I don't really want to push that even with the program already compiled.

I have looked into using the GO AWS SDK for the SecretsManager, but I am not sure if that is the best way to go, or if it will even work like I am hoping it will. What is the best way to handle this?

Thingable
  • 55
  • 2
  • 9

1 Answers1

1

Hardcoding things into the program is obviously never the best choice, so I share your pain and the need for something better, that could be:

  1. Define the connection string into an environment variable. This solution does not keep the information "secret", so if it's something that you would not like to have it readable in any way, try with the next
  2. Define the connection string into Secrets Manager and refer to in the environment variable definition

Doing this with CloudFormation we will have in the first case:

...
Environment:
  -
    Name: CONNECTION_STRING
    Value: 'YOUR VALUE'
...

While in the second case we would have:

...
Environment:
  -
    Name: CONNECTION_STRING
    Value: '{{resolve:secretsmanager:MySecret:SecretString:connection_string}}'
...
Ing. Luca Stucchi
  • 3,070
  • 6
  • 36
  • 58