Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add in AWS env variable which is not a simple string ( contains nested brackets and such )?

I would like to add this environment variable in my aws env.

 GCP_CREDENTIALS={
    "type": "service_account",
    "project_id": "dummy-project-id",
    "private_key_id": "dummy-private-key-id",
    "private_key": "-----BEGIN PRIVATE KEY-----\ndummyPrivateKey\n-----END PRIVATE KEY-----\n",
    "client_email": "[email protected]",
    "client_id": "dummy-client-id",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dummy-client-  email%40dummy-project-id.iam.gserviceaccount.com"
}

How do I do it?

Simply pasting does not work. I think they are expecting a simple string without any brackets.

like image 248
A13rar Avatar asked Oct 14 '25 08:10

A13rar


1 Answers

First, encode the string, including the curly braces, into a base64 string. Then decode and use it wherever you want to in your file. This way, the brackets will be removed, and AWS will identify it as a legit environment variable.

like image 176
Ishmam Hossain Avatar answered Oct 17 '25 00:10

Ishmam Hossain