简体   繁体   中英

aws cli gives access denied when running shell_exect

On the command line I can run:

aws s3 sync s3://my_bucket. --dryrun

just fine.

However, I'm trying to run it as a command in Laravel:

public function handle()
    {
        $command = 'aws s3 sync s3://my_bucket . --dryrun';
        shell_exec($command);
    }

and am getting:

fatal error: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied

Why does the same command work on the command line but not within my PHP application?

I followed the advice of @Sammitch, and used

--profile my_config

where my_config was a named set of configuration parameters created using:

aws configure --profile my_config

Source: AWS creating a named profile

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