AWS Developer Tools Blog
Updated Amazon Cognito Credentials Provider
Amazon Cognito allows you to get temporary AWS credentials, so that you don’t have to distribute your own credentials with your application. Last year we added a Cognito credentials provider to the AWS SDK for .NET to simplify this process.
With the latest update to Cognito, we are now making it even easier to use Cognito with your application. Using the latest version of the SDK, you no longer need to specify IAM roles in your application if you have already associated the correct roles with your identity pool.
Below is an example of how you can construct and use the new credentials provider:
CognitoAWSCredentials credentials = new CognitoAWSCredentials(
identityPoolId, // identity pool id
region); // identity pool region
using (var s3Client = new AmazonS3Client(credentials))
{
s3Client.ListBuckets();
}
Something to note is that even if you have associated roles with an identity pool, you can still specify IAM roles—even ones that are different from the roles configured on the identity pool—when creating these credentials. This gives you finer control over what resources and operations these credentials have access to.