In GitLab's CI/CD pipeline I want to retrieve the secret from AWS secret manager and assigned it to a variable DATABASE_CONNECTION. The runner has access to AWS SM and I would like to use AWS CLI to do that
deploy-dev: # This job runs in the deploy stage.
image: dockerxxxx/awscli
stage: deploy
environment:
name: development
script:
- aws secretsmanager get-secret-value --secret-id MyTestSecret
This returns a JSON something like
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestSecret-a1b2c3",
"Name": "MyTestSecret",
"VersionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"SecretString": "{\"DB_URL\":\"connection string\"}",
"VersionStages": [
"AWSCURRENT"
],
"CreatedDate": 1523477145.713
}
How do I assign value of DB_URL to DATABASE_CONNECTION in script?
I know GitLab has variable option to store secret with Mask On. But for security reason I am not allowed to use that option. GitLab has integration with vault but I don't have that option either