Systems manager execute script failure unable to locate credentials

0

I have a few documents I created in system manager for aws:executeScript but all of them fail for the error nocredentialsError - unable to locate credentials

Here is what one of my scripts looks like: def script_handler(events, context): import boto3 ec2= boto3.client('ec2') response = ec2.describe_regions() print('Regions:' , response['Regions'])

I do have my credentials file set up as [default] region = "us-east-1"

output=json aws_access_key_id = xxxxxxxxxxxxxxxxxxx aws_secret_access_key = xxxxxxxxxxxxxxxx

Obviously I have replaced the keys with Xs for confidentiality

How do I get systems manager to find the credentials so I can run my scripts. Thanks in advance for your help I greatly appreciate it.

  • it works if I hard code my credentials in my script

질문됨 8달 전368회 조회
2개 답변
0

HI, ShamrockAws . Please follow this documentation https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html These must be helpful for your case.

Best regards, Andrii

profile picture
전문가
답변함 8달 전
  • Thanks Andrii, I tried thisimport boto3

    client = boto3.client( 's3', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY, aws_session_token=SESSION_TOKEN )

    but I get NameError name ACCESS_KEY is not defined

0

ACCESS_KEY, SECRET_KEY, and SESSION_TOKEN are variables that contain your access key, secret key, and optional session token. Note that the examples above do not have hard coded credentials. We do not recommend hard coding credentials in your source code.

So please configure this variable to resolve an issue with "NameErro".

profile picture
전문가
답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠