如何在AWS中添加不是简单字符串的环境变量(包含嵌套括号等)?

huangapple go评论58阅读模式
英文:

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

问题

我想在我的 AWS 环境中添加这个环境变量。

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": "dummy-client-email@dummy-project-id.iam.gserviceaccount.com",
    "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"
}
英文:

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": "dummy-client-email@dummy-project-id.iam.gserviceaccount.com",
    "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.

答案1

得分: 5

将字符串,包括大括号,编码为base64字符串。然后解码并在文件中的任何位置使用它。这样,括号将被移除,AWS 将识别它为合法的环境变量。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月15日 00:50:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248652.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定