@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetInstanceProfileResult == false) return false; GetInstanceProfileResult other = (GetInstanceProfileResult) obj; if (other.getInstanceProfile() == null ^ this.getInstanceProfile() == null) return false; if (other.getInstanceProfile() != null && other.getInstanceProfile().equals(this.getInstanceProfile()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceProfile() == null) ? 0 : getInstanceProfile().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInstanceProfile() != null) sb.append("InstanceProfile: ").append(getInstanceProfile()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetInstanceProfileResult == false) return false; GetInstanceProfileResult other = (GetInstanceProfileResult) obj; if (other.getInstanceProfile() == null ^ this.getInstanceProfile() == null) return false; if (other.getInstanceProfile() != null && other.getInstanceProfile().equals(this.getInstanceProfile()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceProfile() == null) ? 0 : getInstanceProfile().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInstanceProfile() != null) sb.append("InstanceProfile: ").append(getInstanceProfile()); sb.append("}"); return sb.toString(); }
/** * Retrieves an IAM profile spec for a given IAM role. Note that the role * needs to already exist. The IAM profile is created if it does not already exist. * * @param iamRole name of the IAM role to be retrieved in profile form * @return IAM instance profile or null if iamRole is null */ private IamInstanceProfileSpecification getIamProfileSpec(String iamRole) { if(null != iamRole) { InstanceProfile instanceProfile; try { GetInstanceProfileResult getProfileResult = iamClient.getInstanceProfile(new GetInstanceProfileRequest() .withInstanceProfileName(iamRole)); instanceProfile = getProfileResult.getInstanceProfile(); } catch (NoSuchEntityException e) { // No existing entity, create one CreateInstanceProfileResult createProfileResult = iamClient.createInstanceProfile(new CreateInstanceProfileRequest() .withInstanceProfileName( iamRole)); instanceProfile = createProfileResult.getInstanceProfile(); } if (null != instanceProfile) { return new IamInstanceProfileSpecification() .withName(instanceProfile.getInstanceProfileName()); } } return null; }
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; }
/** * 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()); } }