Java 类com.amazonaws.services.identitymanagement.model.RemoveRoleFromInstanceProfileRequest 实例源码

项目:cmn-project    文件:DeleteInstanceProfileTask.java   
@Override
public void execute(Context context) throws Exception {
    String name = resource.remoteInstanceProfile.getInstanceProfileName();

    logger.info("delete instance profile and related role and policy, name={}", name);
    if (!resource.remoteInstanceProfile.getRoles().isEmpty()) { // if the associated role doesn't exist anymore, skip to delete (this is not expected state, cmn create role for every instance profile)
        AWS.iam.iam.removeRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest()
            .withInstanceProfileName(name)
            .withRoleName(name));
        AWS.iam.iam.deleteRolePolicy(new DeleteRolePolicyRequest().withRoleName(name).withPolicyName(name));
        AWS.iam.iam.deleteRole(new DeleteRoleRequest().withRoleName(name));
    }
    AWS.iam.iam.deleteInstanceProfile(new DeleteInstanceProfileRequest().withInstanceProfileName(name));
}
项目:aws-ant-tasks    文件:DeployAppToBeanstalkTests.java   
@AfterClass
public static void tearDownAfterClass() throws InterruptedException {
    iamClient
            .removeRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest()
                    .withRoleName("aws-elasticbeanstalk-ec2-role")
                    .withInstanceProfileName(TEST_INSTANCEPROFILE_VALUE));
    iamClient.deleteInstanceProfile(new DeleteInstanceProfileRequest()
            .withInstanceProfileName(TEST_INSTANCEPROFILE_VALUE));
    AWSTestUtils.emptyAndDeleteBucket(s3Client, BUCKET_NAME);
}
项目:aws-ant-tasks    文件:CleanUpBeanstalkTestsTask.java   
public void execute() {
    AmazonIdentityManagementClient iamClient = getOrCreateClient(AmazonIdentityManagementClient.class);
    iamClient
            .removeRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest()
                    .withRoleName(INSTANCEPROFILE_ROLE)
                    .withInstanceProfileName(instanceProfile));
    iamClient.deleteInstanceProfile(new DeleteInstanceProfileRequest()
            .withInstanceProfileName(instanceProfile));
    AmazonS3Client client = getOrCreateClient(AmazonS3Client.class);

    AWSTestUtils.emptyAndDeleteBucket(client, bucketName);
}
项目:datamung    文件:Ec2ActivitiesImpl.java   
/**
 * @inheritDoc
 */
@Override
public void deleteInstanceProfile( String profileName, Identity identity )
{
    AmazonIdentityManagement iam =
        ActivityUtils.createClient( AmazonIdentityManagementClient.class,
                                    identity );

    String roleName = profileName + "-role";
    try
    {
        GetInstanceProfileResult profileResult =
            iam.getInstanceProfile( new GetInstanceProfileRequest().withInstanceProfileName( profileName ) );

        if ( !profileResult.getInstanceProfile().getRoles().isEmpty() )
        {
            iam.removeRoleFromInstanceProfile( new RemoveRoleFromInstanceProfileRequest().withInstanceProfileName( profileName ).withRoleName( roleName ) );
        }

        iam.deleteInstanceProfile( new DeleteInstanceProfileRequest().withInstanceProfileName( profileName ) );
    }
    catch ( NoSuchEntityException e )
    {
        LOG.info( "Instance profile is already gone: " + profileName );
    }
    ActivityUtils.deleteRole( roleName, iam );
}