简体   繁体   中英

Where can I put my .aws/credential file using cloudwatch api?

Anyone helps me how to pass AWS key, secret key and token in CloudWatch function ? I have also tried to pass all the credential array in CloudWatch but its still give me error to pass .aws/credential file, so I also put in my users folder than it give me error permission denied.

Here is function which I am using to implementing the CloudWatch PHP SDK of AWS

$cloudWatchClient = new CloudWatchClient([
    'profile' => 'default',
    'version' => 'latest',
    'region'  => REGION,
]);

I also tried this but it's not working

$credentials = new Aws\Credentials\Credentials(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,TOKEN);


$cloudWatchClient = new CloudWatchClient([
    'profile' => 'default',
    'version'     => 'latest',
    'region'      => REGION,
    'credentials' => $credentials
]);

let me know how can I handle this ? or where can I put this file ?

Can you give a bit more of context? running this locally or trying to run it on an AWS instance or you meant a Lambda Function?

The first code you put will only work on an AWS instance that has a role attached with those permissions.

The second code I imagine you have this ENVS declared somewhere else right ?

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
TOKEN

If you are not using TOKEN you should remove it too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM