當前位置: 首頁>>代碼示例>>Java>>正文


Java GetInstanceProfileRequest類代碼示例

本文整理匯總了Java中com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest的典型用法代碼示例。如果您正苦於以下問題:Java GetInstanceProfileRequest類的具體用法?Java GetInstanceProfileRequest怎麽用?Java GetInstanceProfileRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GetInstanceProfileRequest類屬於com.amazonaws.services.identitymanagement.model包,在下文中一共展示了GetInstanceProfileRequest類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkIamProfileName

import com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest; //導入依賴的package包/類
/**
 * Validates the configured IAM profile.
 *
 * @param configuration       the configuration to be validated
 * @param accumulator         the exception condition accumulator
 * @param localizationContext the localization context
 */
@VisibleForTesting
void checkIamProfileName(Configured configuration,
    PluginExceptionConditionAccumulator accumulator,
    LocalizationContext localizationContext) {

  String iamProfileName =
      configuration.getConfigurationValue(IAM_PROFILE_NAME, localizationContext);

  if (iamProfileName != null) {
    AmazonIdentityManagementClient iamClient = provider.getIdentityManagementClient();

    try {
      iamClient.getInstanceProfile(new GetInstanceProfileRequest()
          .withInstanceProfileName(iamProfileName));

    } catch (NoSuchEntityException e) {
      addError(accumulator, IAM_PROFILE_NAME, localizationContext,
          null, INVALID_IAM_PROFILE_NAME_MSG, iamProfileName);
    }
  }
}
 
開發者ID:cloudera,項目名稱:director-aws-plugin,代碼行數:29,代碼來源:EC2InstanceTemplateConfigurationValidator.java

示例2: readyStackTask

import com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest; //導入依賴的package包/類
private CreateStackTask readyStackTask() {
    CreateStackTask stackTask = new CreateStackTask();
    stackTask.setProject(project);
    stackTask.setName("AntTaskTestStack");
    stackTask.setRegion("us-east-1");
    stackTask
            .setDefaultInstanceProfileArn(iamClient
                    .getInstanceProfile(
                            new GetInstanceProfileRequest()
                                    .withInstanceProfileName("aws-opsworks-ec2-role"))
                    .getInstanceProfile().getArn());
    stackTask.setServiceRoleArn(iamClient
            .getRole(
                    new GetRoleRequest()
                            .withRoleName("aws-opsworks-service-role"))
            .getRole().getArn());

    return stackTask;
}
 
開發者ID:awslabs,項目名稱:aws-ant-tasks,代碼行數:20,代碼來源:OpsWorksDeploymentTests.java

示例3: execute

import com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest; //導入依賴的package包/類
/**
 * Sets the "instanceProfile" and "serviceRole" properties according to the
 * set parameters.
 */
public void execute() {
    checkParams();
    AmazonIdentityManagementClient iamClient = getOrCreateClient(AmazonIdentityManagementClient.class);
    getProject()
            .setProperty(
                    "instanceProfileArn",
                    iamClient
                            .getInstanceProfile(
                                    new GetInstanceProfileRequest()
                                            .withInstanceProfileName(instanceProfile))
                            .getInstanceProfile().getArn());
    getProject()
            .setProperty(
                    "serviceRoleArn",
                    iamClient
                            .getRole(
                                    new GetRoleRequest()
                                            .withRoleName(serviceRole))
                            .getRole().getArn());

}
 
開發者ID:awslabs,項目名稱:aws-ant-tasks,代碼行數:26,代碼來源:SetUpOpsWorksTestsTask.java

示例4: createAgentInstanceProfile

import com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest; //導入依賴的package包/類
/**
 * @inheritDoc
 */
@Override
public void createAgentInstanceProfile( String profileName,
                                        String controlRoleArn,
                                        Identity identity )
{
    AmazonIdentityManagement iam =
        ActivityUtils.createClient( AmazonIdentityManagementClient.class,
                                    identity );

    // Create role if necessary
    String roleName = profileName + "-role";
    Map<String, String> policyVariables = new HashMap<String, String>();
    policyVariables.put( "CONTROLLER_ROLE_ARN", controlRoleArn );
    Role role =
        ActivityUtils.createRole( roleName, iam,
                                  "datamung/agent-policy.json",
                                  policyVariables,
                                  "datamung/agent-trust.json", null );

    // Create instance profile and associate role if necessary
    boolean roleAssociationRequired = true;
    try
    {
        iam.createInstanceProfile( new CreateInstanceProfileRequest().withInstanceProfileName( profileName ).withPath( role.getPath() ) );
    }
    catch ( EntityAlreadyExistsException e )
    {
        LOG.info( "Instance profile " + profileName + " already exists!" );
        roleAssociationRequired =
            iam.getInstanceProfile( new GetInstanceProfileRequest().withInstanceProfileName( profileName ) ).getInstanceProfile().getRoles().isEmpty();
    }
    if ( roleAssociationRequired )
    {
        LOG.info( "Adding role " + roleName + " to instance profile "
            + profileName );
        iam.addRoleToInstanceProfile( new AddRoleToInstanceProfileRequest().withInstanceProfileName( profileName ).withRoleName( roleName ) );
    }
}
 
開發者ID:jiaqi,項目名稱:datamung,代碼行數:42,代碼來源:Ec2ActivitiesImpl.java

示例5: deleteInstanceProfile

import com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest; //導入依賴的package包/類
/**
 * @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 );
}
 
開發者ID:jiaqi,項目名稱:datamung,代碼行數:30,代碼來源:Ec2ActivitiesImpl.java


注:本文中的com.amazonaws.services.identitymanagement.model.GetInstanceProfileRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。