当前位置: 首页>>代码示例>>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;未经允许,请勿转载。