Search code examples
amazon-web-servicesamazon-s3amazon-ec2aws-sdk-go

Does Go AWS SDK require credentials if using EC2 Role?


My EC2 instance has a role attached with S3 permissions. Right now I use my access key and secret access key to load to s3 but I want to rely on the role and get rid of the credentials. Can I do that? Or do I need to have credentials for the Go AWS SDK?

Right now we are using the NewStaticCredentials function to setup our configuration. End goal is to upload files to S3.


Solution

  • This is what i could get from the docs

    If you are running your application on an Amazon EC2 instance, use the instance’s IAM role to get temporary security credentials to make calls to AWS. If you have configured your instance to use IAM roles, the SDK uses these credentials for your application automatically. You don’t need to manually specify these credentials.

    Note:- Even AWS also recommends this.