Skip to content

Commit

Permalink
fixing iam example for javav2
Browse files Browse the repository at this point in the history
  • Loading branch information
soo-aws committed Dec 30, 2017
1 parent 6fde95e commit 7e55d12
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* permissions and limitations under the License.
*/
package com.example.iam;
import software.amazon.awssdk.services.iam.model.StatusType;
import software.amazon.awssdk.services.iam.model.UpdateAccessKeyRequest;
import software.amazon.awssdk.services.iam.model.UpdateAccessKeyResponse;

Expand All @@ -38,14 +39,26 @@ public static void main(String[] args) {
String username = args[0];
String access_id = args[1];
String status = args[2];

StatusType statusType;

if (status.toLowerCase().equalsIgnoreCase("active")) {
statusType = StatusType.ACTIVE;
}
else if (status.toLowerCase().equalsIgnoreCase("inactive")) {
statusType = StatusType.INACTIVE;
}
else {
statusType = StatusType.UNKNOWN_TO_SDK_VERSION;
}

Region region = Region.AWS_GLOBAL;
IAMClient iam = IAMClient.builder().region(region).build();

UpdateAccessKeyRequest request = UpdateAccessKeyRequest.builder()
.accessKeyId(access_id)
.userName(username)
.status(status)
.status(statusType)
.build();

UpdateAccessKeyResponse response = iam.updateAccessKey(request);
Expand Down

0 comments on commit 7e55d12

Please sign in to comment.