public void IdentityManagementServiceCreateInstanceProfile() { #region 5d84e6ae-5921-4e39-8454-10232cd9ff9a var response = client.CreateInstanceProfile(new CreateInstanceProfileRequest { InstanceProfileName = "Webserver" }); InstanceProfile instanceProfile = response.InstanceProfile; #endregion }
private Amazon.IdentityManagement.Model.CreateInstanceProfileResponse CallAWSServiceOperation(IAmazonIdentityManagementService client, Amazon.IdentityManagement.Model.CreateInstanceProfileRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Identity and Access Management", "CreateInstanceProfile"); try { #if DESKTOP return(client.CreateInstanceProfile(request)); #elif CORECLR return(client.CreateInstanceProfileAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
public void IdentityProfiles() { var profiles = client.ListInstanceProfiles().InstanceProfiles; int originalCount = profiles.Count; AssertExtensions.ExpectException(() => client.GetInstanceProfile(new GetInstanceProfileRequest { InstanceProfileName = profileName })); var newProfile = client.CreateInstanceProfile(new CreateInstanceProfileRequest { InstanceProfileName = profileName, Path = path }).InstanceProfile; Assert.IsNotNull(newProfile); profiles = client.ListInstanceProfiles().InstanceProfiles; Assert.AreEqual(originalCount + 1, profiles.Count); var profile = client.GetInstanceProfile(new GetInstanceProfileRequest { InstanceProfileName = profileName }).InstanceProfile; Assert.IsNotNull(profile); AssertExtensions.ExpectException(() => client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest { RoleName = roleName })); // add role to profile var newRole = client.CreateRole(new CreateRoleRequest { RoleName = roleName, Path = path, AssumeRolePolicyDocument = TEST_ASSUME_ALLOW_POLICY }).Role; Assert.IsNotNull(newRole); client.AddRoleToInstanceProfile(new AddRoleToInstanceProfileRequest { InstanceProfileName = profileName, RoleName = roleName }); var roleProfiles = client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest { RoleName = roleName }).InstanceProfiles; Assert.AreEqual(1, roleProfiles.Count); client.RemoveRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest { InstanceProfileName = profileName, RoleName = roleName }); roleProfiles = client.ListInstanceProfilesForRole(new ListInstanceProfilesForRoleRequest { RoleName = roleName }).InstanceProfiles; Assert.AreEqual(0, roleProfiles.Count); client.DeleteInstanceProfile(new DeleteInstanceProfileRequest { InstanceProfileName = profileName }); AssertExtensions.ExpectException(() => client.DeleteInstanceProfile(new DeleteInstanceProfileRequest { InstanceProfileName = profileName })); profiles = client.ListInstanceProfiles().InstanceProfiles; Assert.AreEqual(originalCount, profiles.Count); }