rclone/vendor/github.com/aws/aws-sdk-go/service/iam/examples_test.go

2750 lines
64 KiB
Go

// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package iam_test
import (
"bytes"
"fmt"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
)
var _ time.Duration
var _ bytes.Buffer
func ExampleIAM_AddClientIDToOpenIDConnectProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AddClientIDToOpenIDConnectProviderInput{
ClientID: aws.String("clientIDType"), // Required
OpenIDConnectProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.AddClientIDToOpenIDConnectProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_AddRoleToInstanceProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AddRoleToInstanceProfileInput{
InstanceProfileName: aws.String("instanceProfileNameType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.AddRoleToInstanceProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_AddUserToGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AddUserToGroupInput{
GroupName: aws.String("groupNameType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.AddUserToGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_AttachGroupPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AttachGroupPolicyInput{
GroupName: aws.String("groupNameType"), // Required
PolicyArn: aws.String("arnType"), // Required
}
resp, err := svc.AttachGroupPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_AttachRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AttachRolePolicyInput{
PolicyArn: aws.String("arnType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.AttachRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_AttachUserPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.AttachUserPolicyInput{
PolicyArn: aws.String("arnType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.AttachUserPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ChangePassword() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ChangePasswordInput{
NewPassword: aws.String("passwordType"), // Required
OldPassword: aws.String("passwordType"), // Required
}
resp, err := svc.ChangePassword(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateAccessKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateAccessKeyInput{
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.CreateAccessKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateAccountAlias() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateAccountAliasInput{
AccountAlias: aws.String("accountAliasType"), // Required
}
resp, err := svc.CreateAccountAlias(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateGroupInput{
GroupName: aws.String("groupNameType"), // Required
Path: aws.String("pathType"),
}
resp, err := svc.CreateGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateInstanceProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateInstanceProfileInput{
InstanceProfileName: aws.String("instanceProfileNameType"), // Required
Path: aws.String("pathType"),
}
resp, err := svc.CreateInstanceProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateLoginProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateLoginProfileInput{
Password: aws.String("passwordType"), // Required
UserName: aws.String("userNameType"), // Required
PasswordResetRequired: aws.Bool(true),
}
resp, err := svc.CreateLoginProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateOpenIDConnectProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateOpenIDConnectProviderInput{
ThumbprintList: []*string{ // Required
aws.String("thumbprintType"), // Required
// More values...
},
Url: aws.String("OpenIDConnectProviderUrlType"), // Required
ClientIDList: []*string{
aws.String("clientIDType"), // Required
// More values...
},
}
resp, err := svc.CreateOpenIDConnectProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreatePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreatePolicyInput{
PolicyDocument: aws.String("policyDocumentType"), // Required
PolicyName: aws.String("policyNameType"), // Required
Description: aws.String("policyDescriptionType"),
Path: aws.String("policyPathType"),
}
resp, err := svc.CreatePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreatePolicyVersion() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreatePolicyVersionInput{
PolicyArn: aws.String("arnType"), // Required
PolicyDocument: aws.String("policyDocumentType"), // Required
SetAsDefault: aws.Bool(true),
}
resp, err := svc.CreatePolicyVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateRole() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateRoleInput{
AssumeRolePolicyDocument: aws.String("policyDocumentType"), // Required
RoleName: aws.String("roleNameType"), // Required
Description: aws.String("roleDescriptionType"),
Path: aws.String("pathType"),
}
resp, err := svc.CreateRole(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateSAMLProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateSAMLProviderInput{
Name: aws.String("SAMLProviderNameType"), // Required
SAMLMetadataDocument: aws.String("SAMLMetadataDocumentType"), // Required
}
resp, err := svc.CreateSAMLProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateServiceLinkedRole() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateServiceLinkedRoleInput{
AWSServiceName: aws.String("groupNameType"), // Required
CustomSuffix: aws.String("customSuffixType"),
Description: aws.String("roleDescriptionType"),
}
resp, err := svc.CreateServiceLinkedRole(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateServiceSpecificCredential() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateServiceSpecificCredentialInput{
ServiceName: aws.String("serviceName"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.CreateServiceSpecificCredential(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateUser() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateUserInput{
UserName: aws.String("userNameType"), // Required
Path: aws.String("pathType"),
}
resp, err := svc.CreateUser(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_CreateVirtualMFADevice() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.CreateVirtualMFADeviceInput{
VirtualMFADeviceName: aws.String("virtualMFADeviceName"), // Required
Path: aws.String("pathType"),
}
resp, err := svc.CreateVirtualMFADevice(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeactivateMFADevice() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeactivateMFADeviceInput{
SerialNumber: aws.String("serialNumberType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.DeactivateMFADevice(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteAccessKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteAccessKeyInput{
AccessKeyId: aws.String("accessKeyIdType"), // Required
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.DeleteAccessKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteAccountAlias() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteAccountAliasInput{
AccountAlias: aws.String("accountAliasType"), // Required
}
resp, err := svc.DeleteAccountAlias(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteAccountPasswordPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.DeleteAccountPasswordPolicyInput
resp, err := svc.DeleteAccountPasswordPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteGroupInput{
GroupName: aws.String("groupNameType"), // Required
}
resp, err := svc.DeleteGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteGroupPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteGroupPolicyInput{
GroupName: aws.String("groupNameType"), // Required
PolicyName: aws.String("policyNameType"), // Required
}
resp, err := svc.DeleteGroupPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteInstanceProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteInstanceProfileInput{
InstanceProfileName: aws.String("instanceProfileNameType"), // Required
}
resp, err := svc.DeleteInstanceProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteLoginProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteLoginProfileInput{
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.DeleteLoginProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteOpenIDConnectProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteOpenIDConnectProviderInput{
OpenIDConnectProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.DeleteOpenIDConnectProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeletePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeletePolicyInput{
PolicyArn: aws.String("arnType"), // Required
}
resp, err := svc.DeletePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeletePolicyVersion() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeletePolicyVersionInput{
PolicyArn: aws.String("arnType"), // Required
VersionId: aws.String("policyVersionIdType"), // Required
}
resp, err := svc.DeletePolicyVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteRole() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteRoleInput{
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.DeleteRole(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteRolePolicyInput{
PolicyName: aws.String("policyNameType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.DeleteRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteSAMLProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteSAMLProviderInput{
SAMLProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.DeleteSAMLProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteSSHPublicKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteSSHPublicKeyInput{
SSHPublicKeyId: aws.String("publicKeyIdType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.DeleteSSHPublicKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteServerCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteServerCertificateInput{
ServerCertificateName: aws.String("serverCertificateNameType"), // Required
}
resp, err := svc.DeleteServerCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteServiceSpecificCredential() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteServiceSpecificCredentialInput{
ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required
UserName: aws.String("userNameType"),
}
resp, err := svc.DeleteServiceSpecificCredential(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteSigningCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteSigningCertificateInput{
CertificateId: aws.String("certificateIdType"), // Required
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.DeleteSigningCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteUser() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteUserInput{
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.DeleteUser(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteUserPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteUserPolicyInput{
PolicyName: aws.String("policyNameType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.DeleteUserPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DeleteVirtualMFADevice() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DeleteVirtualMFADeviceInput{
SerialNumber: aws.String("serialNumberType"), // Required
}
resp, err := svc.DeleteVirtualMFADevice(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DetachGroupPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DetachGroupPolicyInput{
GroupName: aws.String("groupNameType"), // Required
PolicyArn: aws.String("arnType"), // Required
}
resp, err := svc.DetachGroupPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DetachRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DetachRolePolicyInput{
PolicyArn: aws.String("arnType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.DetachRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_DetachUserPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.DetachUserPolicyInput{
PolicyArn: aws.String("arnType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.DetachUserPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_EnableMFADevice() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.EnableMFADeviceInput{
AuthenticationCode1: aws.String("authenticationCodeType"), // Required
AuthenticationCode2: aws.String("authenticationCodeType"), // Required
SerialNumber: aws.String("serialNumberType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.EnableMFADevice(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GenerateCredentialReport() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.GenerateCredentialReportInput
resp, err := svc.GenerateCredentialReport(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetAccessKeyLastUsed() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetAccessKeyLastUsedInput{
AccessKeyId: aws.String("accessKeyIdType"), // Required
}
resp, err := svc.GetAccessKeyLastUsed(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetAccountAuthorizationDetails() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetAccountAuthorizationDetailsInput{
Filter: []*string{
aws.String("EntityType"), // Required
// More values...
},
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.GetAccountAuthorizationDetails(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetAccountPasswordPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.GetAccountPasswordPolicyInput
resp, err := svc.GetAccountPasswordPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetAccountSummary() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.GetAccountSummaryInput
resp, err := svc.GetAccountSummary(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetContextKeysForCustomPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetContextKeysForCustomPolicyInput{
PolicyInputList: []*string{ // Required
aws.String("policyDocumentType"), // Required
// More values...
},
}
resp, err := svc.GetContextKeysForCustomPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetContextKeysForPrincipalPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetContextKeysForPrincipalPolicyInput{
PolicySourceArn: aws.String("arnType"), // Required
PolicyInputList: []*string{
aws.String("policyDocumentType"), // Required
// More values...
},
}
resp, err := svc.GetContextKeysForPrincipalPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetCredentialReport() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.GetCredentialReportInput
resp, err := svc.GetCredentialReport(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetGroupInput{
GroupName: aws.String("groupNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.GetGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetGroupPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetGroupPolicyInput{
GroupName: aws.String("groupNameType"), // Required
PolicyName: aws.String("policyNameType"), // Required
}
resp, err := svc.GetGroupPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetInstanceProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetInstanceProfileInput{
InstanceProfileName: aws.String("instanceProfileNameType"), // Required
}
resp, err := svc.GetInstanceProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetLoginProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetLoginProfileInput{
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.GetLoginProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetOpenIDConnectProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetOpenIDConnectProviderInput{
OpenIDConnectProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.GetOpenIDConnectProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetPolicyInput{
PolicyArn: aws.String("arnType"), // Required
}
resp, err := svc.GetPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetPolicyVersion() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetPolicyVersionInput{
PolicyArn: aws.String("arnType"), // Required
VersionId: aws.String("policyVersionIdType"), // Required
}
resp, err := svc.GetPolicyVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetRole() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetRoleInput{
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.GetRole(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetRolePolicyInput{
PolicyName: aws.String("policyNameType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.GetRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetSAMLProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetSAMLProviderInput{
SAMLProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.GetSAMLProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetSSHPublicKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetSSHPublicKeyInput{
Encoding: aws.String("encodingType"), // Required
SSHPublicKeyId: aws.String("publicKeyIdType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.GetSSHPublicKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetServerCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetServerCertificateInput{
ServerCertificateName: aws.String("serverCertificateNameType"), // Required
}
resp, err := svc.GetServerCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetUser() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetUserInput{
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.GetUser(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_GetUserPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.GetUserPolicyInput{
PolicyName: aws.String("policyNameType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.GetUserPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListAccessKeys() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListAccessKeysInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.ListAccessKeys(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListAccountAliases() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListAccountAliasesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListAccountAliases(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListAttachedGroupPolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListAttachedGroupPoliciesInput{
GroupName: aws.String("groupNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("policyPathType"),
}
resp, err := svc.ListAttachedGroupPolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListAttachedRolePolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListAttachedRolePoliciesInput{
RoleName: aws.String("roleNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("policyPathType"),
}
resp, err := svc.ListAttachedRolePolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListAttachedUserPolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListAttachedUserPoliciesInput{
UserName: aws.String("userNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("policyPathType"),
}
resp, err := svc.ListAttachedUserPolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListEntitiesForPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListEntitiesForPolicyInput{
PolicyArn: aws.String("arnType"), // Required
EntityFilter: aws.String("EntityType"),
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathType"),
}
resp, err := svc.ListEntitiesForPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListGroupPolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListGroupPoliciesInput{
GroupName: aws.String("groupNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListGroupPolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListGroups() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListGroupsInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathPrefixType"),
}
resp, err := svc.ListGroups(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListGroupsForUser() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListGroupsForUserInput{
UserName: aws.String("existingUserNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListGroupsForUser(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListInstanceProfiles() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListInstanceProfilesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathPrefixType"),
}
resp, err := svc.ListInstanceProfiles(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListInstanceProfilesForRole() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListInstanceProfilesForRoleInput{
RoleName: aws.String("roleNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListInstanceProfilesForRole(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListMFADevices() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListMFADevicesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.ListMFADevices(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListOpenIDConnectProviders() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.ListOpenIDConnectProvidersInput
resp, err := svc.ListOpenIDConnectProviders(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListPolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListPoliciesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
OnlyAttached: aws.Bool(true),
PathPrefix: aws.String("policyPathType"),
Scope: aws.String("policyScopeType"),
}
resp, err := svc.ListPolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListPolicyVersions() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListPolicyVersionsInput{
PolicyArn: aws.String("arnType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListPolicyVersions(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListRolePolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListRolePoliciesInput{
RoleName: aws.String("roleNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListRolePolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListRoles() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListRolesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathPrefixType"),
}
resp, err := svc.ListRoles(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListSAMLProviders() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
var params *iam.ListSAMLProvidersInput
resp, err := svc.ListSAMLProviders(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListSSHPublicKeys() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListSSHPublicKeysInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
UserName: aws.String("userNameType"),
}
resp, err := svc.ListSSHPublicKeys(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListServerCertificates() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListServerCertificatesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathPrefixType"),
}
resp, err := svc.ListServerCertificates(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListServiceSpecificCredentials() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListServiceSpecificCredentialsInput{
ServiceName: aws.String("serviceName"),
UserName: aws.String("userNameType"),
}
resp, err := svc.ListServiceSpecificCredentials(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListSigningCertificates() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListSigningCertificatesInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.ListSigningCertificates(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListUserPolicies() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListUserPoliciesInput{
UserName: aws.String("existingUserNameType"), // Required
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListUserPolicies(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListUsers() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListUsersInput{
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PathPrefix: aws.String("pathPrefixType"),
}
resp, err := svc.ListUsers(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ListVirtualMFADevices() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ListVirtualMFADevicesInput{
AssignmentStatus: aws.String("assignmentStatusType"),
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListVirtualMFADevices(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_PutGroupPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.PutGroupPolicyInput{
GroupName: aws.String("groupNameType"), // Required
PolicyDocument: aws.String("policyDocumentType"), // Required
PolicyName: aws.String("policyNameType"), // Required
}
resp, err := svc.PutGroupPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_PutRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.PutRolePolicyInput{
PolicyDocument: aws.String("policyDocumentType"), // Required
PolicyName: aws.String("policyNameType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.PutRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_PutUserPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.PutUserPolicyInput{
PolicyDocument: aws.String("policyDocumentType"), // Required
PolicyName: aws.String("policyNameType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.PutUserPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_RemoveClientIDFromOpenIDConnectProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.RemoveClientIDFromOpenIDConnectProviderInput{
ClientID: aws.String("clientIDType"), // Required
OpenIDConnectProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.RemoveClientIDFromOpenIDConnectProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_RemoveRoleFromInstanceProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.RemoveRoleFromInstanceProfileInput{
InstanceProfileName: aws.String("instanceProfileNameType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.RemoveRoleFromInstanceProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_RemoveUserFromGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.RemoveUserFromGroupInput{
GroupName: aws.String("groupNameType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.RemoveUserFromGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ResetServiceSpecificCredential() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ResetServiceSpecificCredentialInput{
ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required
UserName: aws.String("userNameType"),
}
resp, err := svc.ResetServiceSpecificCredential(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_ResyncMFADevice() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.ResyncMFADeviceInput{
AuthenticationCode1: aws.String("authenticationCodeType"), // Required
AuthenticationCode2: aws.String("authenticationCodeType"), // Required
SerialNumber: aws.String("serialNumberType"), // Required
UserName: aws.String("existingUserNameType"), // Required
}
resp, err := svc.ResyncMFADevice(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_SetDefaultPolicyVersion() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.SetDefaultPolicyVersionInput{
PolicyArn: aws.String("arnType"), // Required
VersionId: aws.String("policyVersionIdType"), // Required
}
resp, err := svc.SetDefaultPolicyVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_SimulateCustomPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.SimulateCustomPolicyInput{
ActionNames: []*string{ // Required
aws.String("ActionNameType"), // Required
// More values...
},
PolicyInputList: []*string{ // Required
aws.String("policyDocumentType"), // Required
// More values...
},
CallerArn: aws.String("ResourceNameType"),
ContextEntries: []*iam.ContextEntry{
{ // Required
ContextKeyName: aws.String("ContextKeyNameType"),
ContextKeyType: aws.String("ContextKeyTypeEnum"),
ContextKeyValues: []*string{
aws.String("ContextKeyValueType"), // Required
// More values...
},
},
// More values...
},
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
ResourceArns: []*string{
aws.String("ResourceNameType"), // Required
// More values...
},
ResourceHandlingOption: aws.String("ResourceHandlingOptionType"),
ResourceOwner: aws.String("ResourceNameType"),
ResourcePolicy: aws.String("policyDocumentType"),
}
resp, err := svc.SimulateCustomPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_SimulatePrincipalPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.SimulatePrincipalPolicyInput{
ActionNames: []*string{ // Required
aws.String("ActionNameType"), // Required
// More values...
},
PolicySourceArn: aws.String("arnType"), // Required
CallerArn: aws.String("ResourceNameType"),
ContextEntries: []*iam.ContextEntry{
{ // Required
ContextKeyName: aws.String("ContextKeyNameType"),
ContextKeyType: aws.String("ContextKeyTypeEnum"),
ContextKeyValues: []*string{
aws.String("ContextKeyValueType"), // Required
// More values...
},
},
// More values...
},
Marker: aws.String("markerType"),
MaxItems: aws.Int64(1),
PolicyInputList: []*string{
aws.String("policyDocumentType"), // Required
// More values...
},
ResourceArns: []*string{
aws.String("ResourceNameType"), // Required
// More values...
},
ResourceHandlingOption: aws.String("ResourceHandlingOptionType"),
ResourceOwner: aws.String("ResourceNameType"),
ResourcePolicy: aws.String("policyDocumentType"),
}
resp, err := svc.SimulatePrincipalPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateAccessKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateAccessKeyInput{
AccessKeyId: aws.String("accessKeyIdType"), // Required
Status: aws.String("statusType"), // Required
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.UpdateAccessKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateAccountPasswordPolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateAccountPasswordPolicyInput{
AllowUsersToChangePassword: aws.Bool(true),
HardExpiry: aws.Bool(true),
MaxPasswordAge: aws.Int64(1),
MinimumPasswordLength: aws.Int64(1),
PasswordReusePrevention: aws.Int64(1),
RequireLowercaseCharacters: aws.Bool(true),
RequireNumbers: aws.Bool(true),
RequireSymbols: aws.Bool(true),
RequireUppercaseCharacters: aws.Bool(true),
}
resp, err := svc.UpdateAccountPasswordPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateAssumeRolePolicy() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateAssumeRolePolicyInput{
PolicyDocument: aws.String("policyDocumentType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.UpdateAssumeRolePolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateGroup() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateGroupInput{
GroupName: aws.String("groupNameType"), // Required
NewGroupName: aws.String("groupNameType"),
NewPath: aws.String("pathType"),
}
resp, err := svc.UpdateGroup(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateLoginProfile() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateLoginProfileInput{
UserName: aws.String("userNameType"), // Required
Password: aws.String("passwordType"),
PasswordResetRequired: aws.Bool(true),
}
resp, err := svc.UpdateLoginProfile(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateOpenIDConnectProviderThumbprint() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateOpenIDConnectProviderThumbprintInput{
OpenIDConnectProviderArn: aws.String("arnType"), // Required
ThumbprintList: []*string{ // Required
aws.String("thumbprintType"), // Required
// More values...
},
}
resp, err := svc.UpdateOpenIDConnectProviderThumbprint(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateRoleDescription() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateRoleDescriptionInput{
Description: aws.String("roleDescriptionType"), // Required
RoleName: aws.String("roleNameType"), // Required
}
resp, err := svc.UpdateRoleDescription(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateSAMLProvider() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateSAMLProviderInput{
SAMLMetadataDocument: aws.String("SAMLMetadataDocumentType"), // Required
SAMLProviderArn: aws.String("arnType"), // Required
}
resp, err := svc.UpdateSAMLProvider(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateSSHPublicKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateSSHPublicKeyInput{
SSHPublicKeyId: aws.String("publicKeyIdType"), // Required
Status: aws.String("statusType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.UpdateSSHPublicKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateServerCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateServerCertificateInput{
ServerCertificateName: aws.String("serverCertificateNameType"), // Required
NewPath: aws.String("pathType"),
NewServerCertificateName: aws.String("serverCertificateNameType"),
}
resp, err := svc.UpdateServerCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateServiceSpecificCredential() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateServiceSpecificCredentialInput{
ServiceSpecificCredentialId: aws.String("serviceSpecificCredentialId"), // Required
Status: aws.String("statusType"), // Required
UserName: aws.String("userNameType"),
}
resp, err := svc.UpdateServiceSpecificCredential(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateSigningCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateSigningCertificateInput{
CertificateId: aws.String("certificateIdType"), // Required
Status: aws.String("statusType"), // Required
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.UpdateSigningCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UpdateUser() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UpdateUserInput{
UserName: aws.String("existingUserNameType"), // Required
NewPath: aws.String("pathType"),
NewUserName: aws.String("userNameType"),
}
resp, err := svc.UpdateUser(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UploadSSHPublicKey() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UploadSSHPublicKeyInput{
SSHPublicKeyBody: aws.String("publicKeyMaterialType"), // Required
UserName: aws.String("userNameType"), // Required
}
resp, err := svc.UploadSSHPublicKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UploadServerCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UploadServerCertificateInput{
CertificateBody: aws.String("certificateBodyType"), // Required
PrivateKey: aws.String("privateKeyType"), // Required
ServerCertificateName: aws.String("serverCertificateNameType"), // Required
CertificateChain: aws.String("certificateChainType"),
Path: aws.String("pathType"),
}
resp, err := svc.UploadServerCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleIAM_UploadSigningCertificate() {
sess := session.Must(session.NewSession())
svc := iam.New(sess)
params := &iam.UploadSigningCertificateInput{
CertificateBody: aws.String("certificateBodyType"), // Required
UserName: aws.String("existingUserNameType"),
}
resp, err := svc.UploadSigningCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}