0

Can you give a sample about this question? I've tried something about it but not have succeeded yet. How can I create an account for someone else on my master account?

    @Bean
        public AWSOrganizations createAwsAccount(){
            CreateAccountRequest createAccountRequest = new CreateAccountRequest();
            createAccountRequest.setAccountName("newAccount");
            createAccountRequest.setEmail("newAccount@yandex.com");
            createAccountRequest.setIamUserAccessToBilling("ALLOW");
            //createAccountRequest.setRoleName("");
            AWSCredentials awsCredentials = new ProfileCredentialsProvider().getCredentials();
            final AWSOrganizations awsOrganizations = AWSOrganizationsClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();
            awsOrganizations.createAccount(createAccountRequest);
            return awsOrganizations;
        }

I know, the code I wrote does not make any sense but I just wanted to try something. I'm waiting for your help about this subject.

ErrorMessage: You cannot add accounts to your organization while it is initializing. Try again later.
hsnclk
  • 77
  • 2
  • 12
  • Is `awsOrganizations` ever initialized? – Tdorno Apr 27 '17 at 23:40
  • What is throwing the `NullPointerException` ... the call on `.createAccount()`? As @Tdorno suggests, if that is the case, please share also your code which initializes the client. In general (for AWS client instances) this is code like `AWSOrganizations orgs = new AWSOrganizationsClient.Builder().withFoo(foo).build();` – Jameson Apr 28 '17 at 00:17
  • Hi @Tdorno, thank you for your quick reply. Can you give an example? In this example, I forgot to initialize but when I initialized it, nothing happened. Also, I didn't get any error. – hsnclk Apr 28 '17 at 00:18
  • @Jameson I've updated my codes above. Can you check? I am not getting any errors, but I can not create an account. – hsnclk Apr 28 '17 at 01:06
  • @Tdorno, I've updated my codes above. Can you check? I am not getting any errors, but I can not create an account. – hsnclk Apr 28 '17 at 01:07
  • @hsnclk the code above still doesn't really "make sense", per se. Taking a step back, let me say this. The best way I have found to program for the AWS APIs is to first get a working setup using a scripting language -- e.g., write a shell script with the AWS CLI. Everytime you do a create or update call, you should check status. For this API, that means `describe-create-account-status`. And for every request/result pair, you should always inspect the result. Most of the APIs will throw exceptions to represent 400/500 series errors. Organizations is new and the doco is still a bit light. – Jameson Apr 28 '17 at 01:25
  • @Jameson sorry, I forgot to add this line `awsOrganizations.createAccount(createAccountRequest);` . But now I'm getting the error above. – hsnclk Apr 28 '17 at 03:12
  • I'm getting this same error with a newly created organization through the console, so I don't think it is an API issue. – Dave DeCaprio Jun 14 '17 at 20:18
  • Is resolving this just a matter of waiting a while? – Luke Worth Jul 10 '17 at 05:01

1 Answers1

1

You probably resolved this already, but just in case anyone else finds this:

It seems to be an issue with AWS that is taking them forever to fix!

Look at this thread in the AWS forums. It was opened on March and some (including me) are still having issues. The API call is correct, you just have to either continue waiting (days? weeks?), contact support, or put a message on that topic.

Diego Jancic
  • 7,280
  • 7
  • 52
  • 80
  • Thanks for reply. In that discussion, I have already asked the same question but nobody has returned yet. It seems that there is a bug. – hsnclk Jul 19 '17 at 17:57
  • @hsnclk I finally created a new thread and after a couple days they created a case for me and they were able to resolve it. I would recommend you to either create a new thread asking for that, or if you need it faster, pay for support and create a new case. – Diego Jancic Jul 19 '17 at 22:13
  • BTW, I believe they block that for new accounts. In an old account it was enabled instantly, in a new account I have to explain my use case instead. So it might help if you explain why you want to create new accounts. idk, just a suggestion. – Diego Jancic Jul 19 '17 at 22:14
  • I wanted to create a basic email service like MailChimp using Amazon services. My purpose was that when a user signed up for our system, the program would create an AWS account for themselves. But I couldn't succeed. – hsnclk Jul 20 '17 at 01:22
  • @hsnclk, from a quick look, it doesn't seem like a good approach anyway. But that's a discussion for another topic! – Diego Jancic Jul 20 '17 at 14:29