3

I can get a Credential from FederatedTokenResult by querying AWS. Now, I want that credential to be used by another service to create an application stack using CloudFormation API - I can create that with using my root account which I don't want. But as I read from GetFederationToken and Credential Page, I must must pass to the service API to use the temporary credentials.

Is it possible to do things with temporary users (given permissions) to launch a stack, creating a new Key-Pair? Any links, code snippets are highly appreciated.

Seems ruby sdk provides for session tokens. How do I get it done in Java ?

At the moment I create the stack that is similar to CloudFormation given as sample with AWS SDK which does not use temporary credentials.

1 Answer 1

5

Once you have the Credentials, you create a BasicSessionCredentials object and pass that into the constructor for the AmazonCloudFormationClient. For example:

// Package the temporary security credentials as
// a BasicSessionCredentials object, for an Amazon S3 client object to use.
BasicSessionCredentials basicSessionCredentials = new BasicSessionCredentials(
    sessionCredentials.getAccessKeyId(),
    sessionCredentials.getSecretAccessKey(),
    sessionCredentials.getSessionToken());

// The following will be part of your less trusted code. You provide temporary security
// credentials so it can send authenticated requests to AWS CloudFormation.
AmazonCloudFormationClient client = new AmazonCloudFormationClient(basicSessionCredentials);

I hope that helps!

3
  • Is it possible to create Access Keys using these temporary credentials ?
    – ykesh
    Aug 14, 2013 at 5:47
  • Can you elaborate on what you want to do here? Aug 14, 2013 at 16:44
  • I was trying to use Cloud Formation APIs using temporary credentials and later read here that CloudFormation does not support calling its API with an IAM role which is what I think is used when using Federated Tokens too. I am now using real IAM user credentials to call cloud formation API which works fine.
    – ykesh
    Aug 16, 2013 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.