mardi 21 avril 2015

Not able to create a VPC in AWS using Java SDK

Note: This is the API i am using to create VPC in AWS. But i am facing the below error.        

  1. CreateAccessKeyRequest key = new CreateAccessKeyRequest(); BasicAWSCredentials cred = new BasicAWSCredentials("", ""); key.setRequestCredentials(cred); AmazonEC2 ec2 = new AmazonEC2Client(); System.out.println("Creating VPC.....\n"); CreateVpcRequest newVPC = new CreateVpcRequest("In"); newVPC.setRequestCredentials(key.getRequestCredentials()); String cidrBlock = "192.168.1.70/28"; newVPC.setCidrBlock(cidrBlock); newVPC.setInstanceTenancy(Tenancy.Default); AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(cred); CreateVpcResult res = ec2.createVpc(newVPC); Vpc vp = res.getVpc(); vp.setIsDefault(true); String vpcId = vp.getVpcId(); System.out.println("Created VPC" + vpcId);

    ERROR:: Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain
        at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:117)
        at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:10540)
        at com.amazonaws.services.ec2.AmazonEC2Client.createVpc(AmazonEC2Client.java:5709)
        at CreateUserRequest.main(CreateUserRequest.java:29)
    
    



Aucun commentaire:

Enregistrer un commentaire