简体   繁体   English

在 docker 中未访问 AWS Config 凭证

[英]AWS Config Credentials are not being accessed in docker

I setup secret manager on my local system and now I have.aws directory in my windows root directory.我在本地系统上设置了秘密管理器,现在我的 windows 根目录中有.aws 目录。 And by using the following code, I am retrieving my access-key-id and value.通过使用以下代码,我正在检索我的访问密钥 ID 和值。

client.getSecretValue({SecretId: secretName}, function(err, data) {
// console.log(err);
if (err) {
    console.log(err);
    if (err.code === 'DecryptionFailureException')
        // Secrets Manager can't decrypt the protected secret text using the provided KMS key.
        throw err;
    else if (err.code === 'InternalServiceErrorException')
        // An error occurred on the server side.
        throw err;
    else if (err.code === 'InvalidParameterException')
        // You provided an invalid value for a parameter.
        throw err;
    else if (err.code === 'InvalidRequestException')
        // You provided a parameter value that is not valid for the current state of the resource.
        throw err;
    else if (err.code === 'ResourceNotFoundException')
        // We can't find the resource that you asked for.
        throw err;
}
else {
    
    // Decrypts secret using the associated KMS CMK.
    // Depending on whether the secret is a string or binary, one of these fields will be populated.
    if ('SecretString' in data) {
        secret = JSON.parse(data.SecretString);
        secretKey = secret["AWS_ACCESS_KEY_ID"];
        clientID = secret["AWS_ACCESS_KEY_ID"];
        secret.region = "us-east-1";
        global.secret = secret;
    } else {
        let buff = new Buffer(data.SecretBinary, 'base64');
        decodedBinarySecret = buff.toString('ascii');
    }

    // routes 
   
    require('./services')(router,validation);
}

}); });

It is working well.它运作良好。 But when I run the above code with docker, it gets failed with following error但是当我使用 docker 运行上述代码时,它会因以下错误而失败

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1.配置中缺少凭证,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1。

You can pass these values in as environment variables via the CLI.您可以通过 CLI 将这些值作为环境变量传递。

To do this run using the below syntax为此,请使用以下语法运行

docker run -it -p 3000:3000 -e AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE -e AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY service-docker-image-2:latest .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS SDK 配置中缺少凭据 - AWS SDK Missing credentials in config aws:使用 systemd 时配置中缺少凭据 - aws: missing credentials in config when using systemd AWS Dynamodb 配置中缺少凭证,如果使用 AWS_CONFIG_FILE,则设置 AWS_SDK_LOAD_CONFIG=1 - AWS Dynamodb Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 获取临时AWS凭证的推荐方法? AWS.config还是STS? - Recommended way to get temporary AWS credentials? AWS.config or STS? 错误:配置中缺少凭据,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1 - Error: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 错误 [CredentialsError]:配置中缺少凭据,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1 - Error [CredentialsError]: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 配置中缺少凭据,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1 - Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 错误 [CredentialsError]:配置中缺少凭据,但仅在 Fargate AWS 上运行时 - Error [CredentialsError]: Missing credentials in config, but only when running on Fargate AWS AWS - nodejs SDK - CognitoIdentityServiceProvider.initiateAuth - CredentialsError:配置中缺少凭据 - AWS - nodejs SDK - CognitoIdentityServiceProvider.initiateAuth - CredentialsError: Missing credentials in config 在 NodeJS ExpressJS 应用程序中本地使用共享的 AWS 配置/凭证文件 - Using shared AWS config/credentials files locally in NodeJS ExpressJS app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM