github.com/aavshr/aws-sdk-go@v1.41.3/service/iam/examples_test.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package iam_test
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  	"time"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    12  	"github.com/aavshr/aws-sdk-go/aws/session"
    13  	"github.com/aavshr/aws-sdk-go/service/iam"
    14  )
    15  
    16  var _ time.Duration
    17  var _ strings.Reader
    18  var _ aws.Config
    19  
    20  func parseTime(layout, value string) *time.Time {
    21  	t, err := time.Parse(layout, value)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	return &t
    26  }
    27  
    28  // To add a client ID (audience) to an Open-ID Connect (OIDC) provider
    29  //
    30  // The following add-client-id-to-open-id-connect-provider command adds the client ID
    31  // my-application-ID to the OIDC provider named server.example.com:
    32  func ExampleIAM_AddClientIDToOpenIDConnectProvider_shared00() {
    33  	svc := iam.New(session.New())
    34  	input := &iam.AddClientIDToOpenIDConnectProviderInput{
    35  		ClientID:                 aws.String("my-application-ID"),
    36  		OpenIDConnectProviderArn: aws.String("arn:aws:iam::123456789012:oidc-provider/server.example.com"),
    37  	}
    38  
    39  	result, err := svc.AddClientIDToOpenIDConnectProvider(input)
    40  	if err != nil {
    41  		if aerr, ok := err.(awserr.Error); ok {
    42  			switch aerr.Code() {
    43  			case iam.ErrCodeInvalidInputException:
    44  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
    45  			case iam.ErrCodeNoSuchEntityException:
    46  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
    47  			case iam.ErrCodeLimitExceededException:
    48  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
    49  			case iam.ErrCodeServiceFailureException:
    50  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
    51  			default:
    52  				fmt.Println(aerr.Error())
    53  			}
    54  		} else {
    55  			// Print the error, cast err to awserr.Error to get the Code and
    56  			// Message from an error.
    57  			fmt.Println(err.Error())
    58  		}
    59  		return
    60  	}
    61  
    62  	fmt.Println(result)
    63  }
    64  
    65  // To add a role to an instance profile
    66  //
    67  // The following command adds the role named S3Access to the instance profile named
    68  // Webserver:
    69  func ExampleIAM_AddRoleToInstanceProfile_shared00() {
    70  	svc := iam.New(session.New())
    71  	input := &iam.AddRoleToInstanceProfileInput{
    72  		InstanceProfileName: aws.String("Webserver"),
    73  		RoleName:            aws.String("S3Access"),
    74  	}
    75  
    76  	result, err := svc.AddRoleToInstanceProfile(input)
    77  	if err != nil {
    78  		if aerr, ok := err.(awserr.Error); ok {
    79  			switch aerr.Code() {
    80  			case iam.ErrCodeNoSuchEntityException:
    81  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
    82  			case iam.ErrCodeEntityAlreadyExistsException:
    83  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
    84  			case iam.ErrCodeLimitExceededException:
    85  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
    86  			case iam.ErrCodeUnmodifiableEntityException:
    87  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
    88  			case iam.ErrCodeServiceFailureException:
    89  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
    90  			default:
    91  				fmt.Println(aerr.Error())
    92  			}
    93  		} else {
    94  			// Print the error, cast err to awserr.Error to get the Code and
    95  			// Message from an error.
    96  			fmt.Println(err.Error())
    97  		}
    98  		return
    99  	}
   100  
   101  	fmt.Println(result)
   102  }
   103  
   104  // To add a user to an IAM group
   105  //
   106  // The following command adds an IAM user named Bob to the IAM group named Admins:
   107  func ExampleIAM_AddUserToGroup_shared00() {
   108  	svc := iam.New(session.New())
   109  	input := &iam.AddUserToGroupInput{
   110  		GroupName: aws.String("Admins"),
   111  		UserName:  aws.String("Bob"),
   112  	}
   113  
   114  	result, err := svc.AddUserToGroup(input)
   115  	if err != nil {
   116  		if aerr, ok := err.(awserr.Error); ok {
   117  			switch aerr.Code() {
   118  			case iam.ErrCodeNoSuchEntityException:
   119  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   120  			case iam.ErrCodeLimitExceededException:
   121  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   122  			case iam.ErrCodeServiceFailureException:
   123  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   124  			default:
   125  				fmt.Println(aerr.Error())
   126  			}
   127  		} else {
   128  			// Print the error, cast err to awserr.Error to get the Code and
   129  			// Message from an error.
   130  			fmt.Println(err.Error())
   131  		}
   132  		return
   133  	}
   134  
   135  	fmt.Println(result)
   136  }
   137  
   138  // To attach a managed policy to an IAM group
   139  //
   140  // The following command attaches the AWS managed policy named ReadOnlyAccess to the
   141  // IAM group named Finance.
   142  func ExampleIAM_AttachGroupPolicy_shared00() {
   143  	svc := iam.New(session.New())
   144  	input := &iam.AttachGroupPolicyInput{
   145  		GroupName: aws.String("Finance"),
   146  		PolicyArn: aws.String("arn:aws:iam::aws:policy/ReadOnlyAccess"),
   147  	}
   148  
   149  	result, err := svc.AttachGroupPolicy(input)
   150  	if err != nil {
   151  		if aerr, ok := err.(awserr.Error); ok {
   152  			switch aerr.Code() {
   153  			case iam.ErrCodeNoSuchEntityException:
   154  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   155  			case iam.ErrCodeLimitExceededException:
   156  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   157  			case iam.ErrCodeInvalidInputException:
   158  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   159  			case iam.ErrCodePolicyNotAttachableException:
   160  				fmt.Println(iam.ErrCodePolicyNotAttachableException, aerr.Error())
   161  			case iam.ErrCodeServiceFailureException:
   162  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   163  			default:
   164  				fmt.Println(aerr.Error())
   165  			}
   166  		} else {
   167  			// Print the error, cast err to awserr.Error to get the Code and
   168  			// Message from an error.
   169  			fmt.Println(err.Error())
   170  		}
   171  		return
   172  	}
   173  
   174  	fmt.Println(result)
   175  }
   176  
   177  // To attach a managed policy to an IAM role
   178  //
   179  // The following command attaches the AWS managed policy named ReadOnlyAccess to the
   180  // IAM role named ReadOnlyRole.
   181  func ExampleIAM_AttachRolePolicy_shared00() {
   182  	svc := iam.New(session.New())
   183  	input := &iam.AttachRolePolicyInput{
   184  		PolicyArn: aws.String("arn:aws:iam::aws:policy/ReadOnlyAccess"),
   185  		RoleName:  aws.String("ReadOnlyRole"),
   186  	}
   187  
   188  	result, err := svc.AttachRolePolicy(input)
   189  	if err != nil {
   190  		if aerr, ok := err.(awserr.Error); ok {
   191  			switch aerr.Code() {
   192  			case iam.ErrCodeNoSuchEntityException:
   193  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   194  			case iam.ErrCodeLimitExceededException:
   195  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   196  			case iam.ErrCodeInvalidInputException:
   197  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   198  			case iam.ErrCodeUnmodifiableEntityException:
   199  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
   200  			case iam.ErrCodePolicyNotAttachableException:
   201  				fmt.Println(iam.ErrCodePolicyNotAttachableException, aerr.Error())
   202  			case iam.ErrCodeServiceFailureException:
   203  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   204  			default:
   205  				fmt.Println(aerr.Error())
   206  			}
   207  		} else {
   208  			// Print the error, cast err to awserr.Error to get the Code and
   209  			// Message from an error.
   210  			fmt.Println(err.Error())
   211  		}
   212  		return
   213  	}
   214  
   215  	fmt.Println(result)
   216  }
   217  
   218  // To attach a managed policy to an IAM user
   219  //
   220  // The following command attaches the AWS managed policy named AdministratorAccess to
   221  // the IAM user named Alice.
   222  func ExampleIAM_AttachUserPolicy_shared00() {
   223  	svc := iam.New(session.New())
   224  	input := &iam.AttachUserPolicyInput{
   225  		PolicyArn: aws.String("arn:aws:iam::aws:policy/AdministratorAccess"),
   226  		UserName:  aws.String("Alice"),
   227  	}
   228  
   229  	result, err := svc.AttachUserPolicy(input)
   230  	if err != nil {
   231  		if aerr, ok := err.(awserr.Error); ok {
   232  			switch aerr.Code() {
   233  			case iam.ErrCodeNoSuchEntityException:
   234  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   235  			case iam.ErrCodeLimitExceededException:
   236  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   237  			case iam.ErrCodeInvalidInputException:
   238  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   239  			case iam.ErrCodePolicyNotAttachableException:
   240  				fmt.Println(iam.ErrCodePolicyNotAttachableException, aerr.Error())
   241  			case iam.ErrCodeServiceFailureException:
   242  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   243  			default:
   244  				fmt.Println(aerr.Error())
   245  			}
   246  		} else {
   247  			// Print the error, cast err to awserr.Error to get the Code and
   248  			// Message from an error.
   249  			fmt.Println(err.Error())
   250  		}
   251  		return
   252  	}
   253  
   254  	fmt.Println(result)
   255  }
   256  
   257  // To change the password for your IAM user
   258  //
   259  // The following command changes the password for the current IAM user.
   260  func ExampleIAM_ChangePassword_shared00() {
   261  	svc := iam.New(session.New())
   262  	input := &iam.ChangePasswordInput{
   263  		NewPassword: aws.String("]35d/{pB9Fo9wJ"),
   264  		OldPassword: aws.String("3s0K_;xh4~8XXI"),
   265  	}
   266  
   267  	result, err := svc.ChangePassword(input)
   268  	if err != nil {
   269  		if aerr, ok := err.(awserr.Error); ok {
   270  			switch aerr.Code() {
   271  			case iam.ErrCodeNoSuchEntityException:
   272  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   273  			case iam.ErrCodeInvalidUserTypeException:
   274  				fmt.Println(iam.ErrCodeInvalidUserTypeException, aerr.Error())
   275  			case iam.ErrCodeLimitExceededException:
   276  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   277  			case iam.ErrCodeEntityTemporarilyUnmodifiableException:
   278  				fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error())
   279  			case iam.ErrCodePasswordPolicyViolationException:
   280  				fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error())
   281  			case iam.ErrCodeServiceFailureException:
   282  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   283  			default:
   284  				fmt.Println(aerr.Error())
   285  			}
   286  		} else {
   287  			// Print the error, cast err to awserr.Error to get the Code and
   288  			// Message from an error.
   289  			fmt.Println(err.Error())
   290  		}
   291  		return
   292  	}
   293  
   294  	fmt.Println(result)
   295  }
   296  
   297  // To create an access key for an IAM user
   298  //
   299  // The following command creates an access key (access key ID and secret access key)
   300  // for the IAM user named Bob.
   301  func ExampleIAM_CreateAccessKey_shared00() {
   302  	svc := iam.New(session.New())
   303  	input := &iam.CreateAccessKeyInput{
   304  		UserName: aws.String("Bob"),
   305  	}
   306  
   307  	result, err := svc.CreateAccessKey(input)
   308  	if err != nil {
   309  		if aerr, ok := err.(awserr.Error); ok {
   310  			switch aerr.Code() {
   311  			case iam.ErrCodeNoSuchEntityException:
   312  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   313  			case iam.ErrCodeLimitExceededException:
   314  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   315  			case iam.ErrCodeServiceFailureException:
   316  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   317  			default:
   318  				fmt.Println(aerr.Error())
   319  			}
   320  		} else {
   321  			// Print the error, cast err to awserr.Error to get the Code and
   322  			// Message from an error.
   323  			fmt.Println(err.Error())
   324  		}
   325  		return
   326  	}
   327  
   328  	fmt.Println(result)
   329  }
   330  
   331  // To create an account alias
   332  //
   333  // The following command associates the alias examplecorp to your AWS account.
   334  func ExampleIAM_CreateAccountAlias_shared00() {
   335  	svc := iam.New(session.New())
   336  	input := &iam.CreateAccountAliasInput{
   337  		AccountAlias: aws.String("examplecorp"),
   338  	}
   339  
   340  	result, err := svc.CreateAccountAlias(input)
   341  	if err != nil {
   342  		if aerr, ok := err.(awserr.Error); ok {
   343  			switch aerr.Code() {
   344  			case iam.ErrCodeEntityAlreadyExistsException:
   345  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   346  			case iam.ErrCodeLimitExceededException:
   347  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   348  			case iam.ErrCodeServiceFailureException:
   349  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   350  			default:
   351  				fmt.Println(aerr.Error())
   352  			}
   353  		} else {
   354  			// Print the error, cast err to awserr.Error to get the Code and
   355  			// Message from an error.
   356  			fmt.Println(err.Error())
   357  		}
   358  		return
   359  	}
   360  
   361  	fmt.Println(result)
   362  }
   363  
   364  // To create an IAM group
   365  //
   366  // The following command creates an IAM group named Admins.
   367  func ExampleIAM_CreateGroup_shared00() {
   368  	svc := iam.New(session.New())
   369  	input := &iam.CreateGroupInput{
   370  		GroupName: aws.String("Admins"),
   371  	}
   372  
   373  	result, err := svc.CreateGroup(input)
   374  	if err != nil {
   375  		if aerr, ok := err.(awserr.Error); ok {
   376  			switch aerr.Code() {
   377  			case iam.ErrCodeLimitExceededException:
   378  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   379  			case iam.ErrCodeEntityAlreadyExistsException:
   380  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   381  			case iam.ErrCodeNoSuchEntityException:
   382  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   383  			case iam.ErrCodeServiceFailureException:
   384  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   385  			default:
   386  				fmt.Println(aerr.Error())
   387  			}
   388  		} else {
   389  			// Print the error, cast err to awserr.Error to get the Code and
   390  			// Message from an error.
   391  			fmt.Println(err.Error())
   392  		}
   393  		return
   394  	}
   395  
   396  	fmt.Println(result)
   397  }
   398  
   399  // To create an instance profile
   400  //
   401  // The following command creates an instance profile named Webserver that is ready to
   402  // have a role attached and then be associated with an EC2 instance.
   403  func ExampleIAM_CreateInstanceProfile_shared00() {
   404  	svc := iam.New(session.New())
   405  	input := &iam.CreateInstanceProfileInput{
   406  		InstanceProfileName: aws.String("Webserver"),
   407  	}
   408  
   409  	result, err := svc.CreateInstanceProfile(input)
   410  	if err != nil {
   411  		if aerr, ok := err.(awserr.Error); ok {
   412  			switch aerr.Code() {
   413  			case iam.ErrCodeEntityAlreadyExistsException:
   414  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   415  			case iam.ErrCodeInvalidInputException:
   416  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   417  			case iam.ErrCodeLimitExceededException:
   418  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   419  			case iam.ErrCodeConcurrentModificationException:
   420  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   421  			case iam.ErrCodeServiceFailureException:
   422  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   423  			default:
   424  				fmt.Println(aerr.Error())
   425  			}
   426  		} else {
   427  			// Print the error, cast err to awserr.Error to get the Code and
   428  			// Message from an error.
   429  			fmt.Println(err.Error())
   430  		}
   431  		return
   432  	}
   433  
   434  	fmt.Println(result)
   435  }
   436  
   437  // To create an instance profile
   438  //
   439  // The following command changes IAM user Bob's password and sets the flag that required
   440  // Bob to change the password the next time he signs in.
   441  func ExampleIAM_CreateLoginProfile_shared00() {
   442  	svc := iam.New(session.New())
   443  	input := &iam.CreateLoginProfileInput{
   444  		Password:              aws.String("h]6EszR}vJ*m"),
   445  		PasswordResetRequired: aws.Bool(true),
   446  		UserName:              aws.String("Bob"),
   447  	}
   448  
   449  	result, err := svc.CreateLoginProfile(input)
   450  	if err != nil {
   451  		if aerr, ok := err.(awserr.Error); ok {
   452  			switch aerr.Code() {
   453  			case iam.ErrCodeEntityAlreadyExistsException:
   454  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   455  			case iam.ErrCodeNoSuchEntityException:
   456  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   457  			case iam.ErrCodePasswordPolicyViolationException:
   458  				fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error())
   459  			case iam.ErrCodeLimitExceededException:
   460  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   461  			case iam.ErrCodeServiceFailureException:
   462  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   463  			default:
   464  				fmt.Println(aerr.Error())
   465  			}
   466  		} else {
   467  			// Print the error, cast err to awserr.Error to get the Code and
   468  			// Message from an error.
   469  			fmt.Println(err.Error())
   470  		}
   471  		return
   472  	}
   473  
   474  	fmt.Println(result)
   475  }
   476  
   477  // To create an instance profile
   478  //
   479  // The following example defines a new OIDC provider in IAM with a client ID of my-application-id
   480  // and pointing at the server with a URL of https://server.example.com.
   481  func ExampleIAM_CreateOpenIDConnectProvider_shared00() {
   482  	svc := iam.New(session.New())
   483  	input := &iam.CreateOpenIDConnectProviderInput{
   484  		ClientIDList: []*string{
   485  			aws.String("my-application-id"),
   486  		},
   487  		ThumbprintList: []*string{
   488  			aws.String("3768084dfb3d2b68b7897bf5f565da8efEXAMPLE"),
   489  		},
   490  		Url: aws.String("https://server.example.com"),
   491  	}
   492  
   493  	result, err := svc.CreateOpenIDConnectProvider(input)
   494  	if err != nil {
   495  		if aerr, ok := err.(awserr.Error); ok {
   496  			switch aerr.Code() {
   497  			case iam.ErrCodeInvalidInputException:
   498  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   499  			case iam.ErrCodeEntityAlreadyExistsException:
   500  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   501  			case iam.ErrCodeLimitExceededException:
   502  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   503  			case iam.ErrCodeConcurrentModificationException:
   504  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   505  			case iam.ErrCodeServiceFailureException:
   506  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   507  			default:
   508  				fmt.Println(aerr.Error())
   509  			}
   510  		} else {
   511  			// Print the error, cast err to awserr.Error to get the Code and
   512  			// Message from an error.
   513  			fmt.Println(err.Error())
   514  		}
   515  		return
   516  	}
   517  
   518  	fmt.Println(result)
   519  }
   520  
   521  // To create an IAM role
   522  //
   523  // The following command creates a role named Test-Role and attaches a trust policy
   524  // that you must convert from JSON to a string. Upon success, the response includes
   525  // the same policy as a URL-encoded JSON string.
   526  func ExampleIAM_CreateRole_shared00() {
   527  	svc := iam.New(session.New())
   528  	input := &iam.CreateRoleInput{
   529  		AssumeRolePolicyDocument: aws.String("<Stringified-JSON>"),
   530  		Path:                     aws.String("/"),
   531  		RoleName:                 aws.String("Test-Role"),
   532  	}
   533  
   534  	result, err := svc.CreateRole(input)
   535  	if err != nil {
   536  		if aerr, ok := err.(awserr.Error); ok {
   537  			switch aerr.Code() {
   538  			case iam.ErrCodeLimitExceededException:
   539  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   540  			case iam.ErrCodeInvalidInputException:
   541  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   542  			case iam.ErrCodeEntityAlreadyExistsException:
   543  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   544  			case iam.ErrCodeMalformedPolicyDocumentException:
   545  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
   546  			case iam.ErrCodeConcurrentModificationException:
   547  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   548  			case iam.ErrCodeServiceFailureException:
   549  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   550  			default:
   551  				fmt.Println(aerr.Error())
   552  			}
   553  		} else {
   554  			// Print the error, cast err to awserr.Error to get the Code and
   555  			// Message from an error.
   556  			fmt.Println(err.Error())
   557  		}
   558  		return
   559  	}
   560  
   561  	fmt.Println(result)
   562  }
   563  
   564  // To create an IAM user
   565  //
   566  // The following create-user command creates an IAM user named Bob in the current account.
   567  func ExampleIAM_CreateUser_shared00() {
   568  	svc := iam.New(session.New())
   569  	input := &iam.CreateUserInput{
   570  		UserName: aws.String("Bob"),
   571  	}
   572  
   573  	result, err := svc.CreateUser(input)
   574  	if err != nil {
   575  		if aerr, ok := err.(awserr.Error); ok {
   576  			switch aerr.Code() {
   577  			case iam.ErrCodeLimitExceededException:
   578  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   579  			case iam.ErrCodeEntityAlreadyExistsException:
   580  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
   581  			case iam.ErrCodeNoSuchEntityException:
   582  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   583  			case iam.ErrCodeInvalidInputException:
   584  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
   585  			case iam.ErrCodeConcurrentModificationException:
   586  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   587  			case iam.ErrCodeServiceFailureException:
   588  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   589  			default:
   590  				fmt.Println(aerr.Error())
   591  			}
   592  		} else {
   593  			// Print the error, cast err to awserr.Error to get the Code and
   594  			// Message from an error.
   595  			fmt.Println(err.Error())
   596  		}
   597  		return
   598  	}
   599  
   600  	fmt.Println(result)
   601  }
   602  
   603  // To delete an access key for an IAM user
   604  //
   605  // The following command deletes one access key (access key ID and secret access key)
   606  // assigned to the IAM user named Bob.
   607  func ExampleIAM_DeleteAccessKey_shared00() {
   608  	svc := iam.New(session.New())
   609  	input := &iam.DeleteAccessKeyInput{
   610  		AccessKeyId: aws.String("AKIDPMS9RO4H3FEXAMPLE"),
   611  		UserName:    aws.String("Bob"),
   612  	}
   613  
   614  	result, err := svc.DeleteAccessKey(input)
   615  	if err != nil {
   616  		if aerr, ok := err.(awserr.Error); ok {
   617  			switch aerr.Code() {
   618  			case iam.ErrCodeNoSuchEntityException:
   619  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   620  			case iam.ErrCodeLimitExceededException:
   621  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   622  			case iam.ErrCodeServiceFailureException:
   623  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   624  			default:
   625  				fmt.Println(aerr.Error())
   626  			}
   627  		} else {
   628  			// Print the error, cast err to awserr.Error to get the Code and
   629  			// Message from an error.
   630  			fmt.Println(err.Error())
   631  		}
   632  		return
   633  	}
   634  
   635  	fmt.Println(result)
   636  }
   637  
   638  // To delete an account alias
   639  //
   640  // The following command removes the alias mycompany from the current AWS account:
   641  func ExampleIAM_DeleteAccountAlias_shared00() {
   642  	svc := iam.New(session.New())
   643  	input := &iam.DeleteAccountAliasInput{
   644  		AccountAlias: aws.String("mycompany"),
   645  	}
   646  
   647  	result, err := svc.DeleteAccountAlias(input)
   648  	if err != nil {
   649  		if aerr, ok := err.(awserr.Error); ok {
   650  			switch aerr.Code() {
   651  			case iam.ErrCodeNoSuchEntityException:
   652  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   653  			case iam.ErrCodeLimitExceededException:
   654  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   655  			case iam.ErrCodeServiceFailureException:
   656  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   657  			default:
   658  				fmt.Println(aerr.Error())
   659  			}
   660  		} else {
   661  			// Print the error, cast err to awserr.Error to get the Code and
   662  			// Message from an error.
   663  			fmt.Println(err.Error())
   664  		}
   665  		return
   666  	}
   667  
   668  	fmt.Println(result)
   669  }
   670  
   671  // To delete the current account password policy
   672  //
   673  // The following command removes the password policy from the current AWS account:
   674  func ExampleIAM_DeleteAccountPasswordPolicy_shared00() {
   675  	svc := iam.New(session.New())
   676  	input := &iam.DeleteAccountPasswordPolicyInput{}
   677  
   678  	result, err := svc.DeleteAccountPasswordPolicy(input)
   679  	if err != nil {
   680  		if aerr, ok := err.(awserr.Error); ok {
   681  			switch aerr.Code() {
   682  			case iam.ErrCodeNoSuchEntityException:
   683  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   684  			case iam.ErrCodeLimitExceededException:
   685  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   686  			case iam.ErrCodeServiceFailureException:
   687  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   688  			default:
   689  				fmt.Println(aerr.Error())
   690  			}
   691  		} else {
   692  			// Print the error, cast err to awserr.Error to get the Code and
   693  			// Message from an error.
   694  			fmt.Println(err.Error())
   695  		}
   696  		return
   697  	}
   698  
   699  	fmt.Println(result)
   700  }
   701  
   702  // To delete a policy from an IAM group
   703  //
   704  // The following command deletes the policy named ExamplePolicy from the group named
   705  // Admins:
   706  func ExampleIAM_DeleteGroupPolicy_shared00() {
   707  	svc := iam.New(session.New())
   708  	input := &iam.DeleteGroupPolicyInput{
   709  		GroupName:  aws.String("Admins"),
   710  		PolicyName: aws.String("ExamplePolicy"),
   711  	}
   712  
   713  	result, err := svc.DeleteGroupPolicy(input)
   714  	if err != nil {
   715  		if aerr, ok := err.(awserr.Error); ok {
   716  			switch aerr.Code() {
   717  			case iam.ErrCodeNoSuchEntityException:
   718  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   719  			case iam.ErrCodeLimitExceededException:
   720  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   721  			case iam.ErrCodeServiceFailureException:
   722  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   723  			default:
   724  				fmt.Println(aerr.Error())
   725  			}
   726  		} else {
   727  			// Print the error, cast err to awserr.Error to get the Code and
   728  			// Message from an error.
   729  			fmt.Println(err.Error())
   730  		}
   731  		return
   732  	}
   733  
   734  	fmt.Println(result)
   735  }
   736  
   737  // To delete an instance profile
   738  //
   739  // The following command deletes the instance profile named ExampleInstanceProfile
   740  func ExampleIAM_DeleteInstanceProfile_shared00() {
   741  	svc := iam.New(session.New())
   742  	input := &iam.DeleteInstanceProfileInput{
   743  		InstanceProfileName: aws.String("ExampleInstanceProfile"),
   744  	}
   745  
   746  	result, err := svc.DeleteInstanceProfile(input)
   747  	if err != nil {
   748  		if aerr, ok := err.(awserr.Error); ok {
   749  			switch aerr.Code() {
   750  			case iam.ErrCodeNoSuchEntityException:
   751  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   752  			case iam.ErrCodeDeleteConflictException:
   753  				fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error())
   754  			case iam.ErrCodeLimitExceededException:
   755  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   756  			case iam.ErrCodeServiceFailureException:
   757  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   758  			default:
   759  				fmt.Println(aerr.Error())
   760  			}
   761  		} else {
   762  			// Print the error, cast err to awserr.Error to get the Code and
   763  			// Message from an error.
   764  			fmt.Println(err.Error())
   765  		}
   766  		return
   767  	}
   768  
   769  	fmt.Println(result)
   770  }
   771  
   772  // To delete a password for an IAM user
   773  //
   774  // The following command deletes the password for the IAM user named Bob.
   775  func ExampleIAM_DeleteLoginProfile_shared00() {
   776  	svc := iam.New(session.New())
   777  	input := &iam.DeleteLoginProfileInput{
   778  		UserName: aws.String("Bob"),
   779  	}
   780  
   781  	result, err := svc.DeleteLoginProfile(input)
   782  	if err != nil {
   783  		if aerr, ok := err.(awserr.Error); ok {
   784  			switch aerr.Code() {
   785  			case iam.ErrCodeEntityTemporarilyUnmodifiableException:
   786  				fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error())
   787  			case iam.ErrCodeNoSuchEntityException:
   788  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   789  			case iam.ErrCodeLimitExceededException:
   790  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   791  			case iam.ErrCodeServiceFailureException:
   792  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   793  			default:
   794  				fmt.Println(aerr.Error())
   795  			}
   796  		} else {
   797  			// Print the error, cast err to awserr.Error to get the Code and
   798  			// Message from an error.
   799  			fmt.Println(err.Error())
   800  		}
   801  		return
   802  	}
   803  
   804  	fmt.Println(result)
   805  }
   806  
   807  // To delete an IAM role
   808  //
   809  // The following command removes the role named Test-Role.
   810  func ExampleIAM_DeleteRole_shared00() {
   811  	svc := iam.New(session.New())
   812  	input := &iam.DeleteRoleInput{
   813  		RoleName: aws.String("Test-Role"),
   814  	}
   815  
   816  	result, err := svc.DeleteRole(input)
   817  	if err != nil {
   818  		if aerr, ok := err.(awserr.Error); ok {
   819  			switch aerr.Code() {
   820  			case iam.ErrCodeNoSuchEntityException:
   821  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   822  			case iam.ErrCodeDeleteConflictException:
   823  				fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error())
   824  			case iam.ErrCodeLimitExceededException:
   825  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   826  			case iam.ErrCodeUnmodifiableEntityException:
   827  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
   828  			case iam.ErrCodeConcurrentModificationException:
   829  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   830  			case iam.ErrCodeServiceFailureException:
   831  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   832  			default:
   833  				fmt.Println(aerr.Error())
   834  			}
   835  		} else {
   836  			// Print the error, cast err to awserr.Error to get the Code and
   837  			// Message from an error.
   838  			fmt.Println(err.Error())
   839  		}
   840  		return
   841  	}
   842  
   843  	fmt.Println(result)
   844  }
   845  
   846  // To remove a policy from an IAM role
   847  //
   848  // The following command removes the policy named ExamplePolicy from the role named
   849  // Test-Role.
   850  func ExampleIAM_DeleteRolePolicy_shared00() {
   851  	svc := iam.New(session.New())
   852  	input := &iam.DeleteRolePolicyInput{
   853  		PolicyName: aws.String("ExamplePolicy"),
   854  		RoleName:   aws.String("Test-Role"),
   855  	}
   856  
   857  	result, err := svc.DeleteRolePolicy(input)
   858  	if err != nil {
   859  		if aerr, ok := err.(awserr.Error); ok {
   860  			switch aerr.Code() {
   861  			case iam.ErrCodeNoSuchEntityException:
   862  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   863  			case iam.ErrCodeLimitExceededException:
   864  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   865  			case iam.ErrCodeUnmodifiableEntityException:
   866  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
   867  			case iam.ErrCodeServiceFailureException:
   868  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   869  			default:
   870  				fmt.Println(aerr.Error())
   871  			}
   872  		} else {
   873  			// Print the error, cast err to awserr.Error to get the Code and
   874  			// Message from an error.
   875  			fmt.Println(err.Error())
   876  		}
   877  		return
   878  	}
   879  
   880  	fmt.Println(result)
   881  }
   882  
   883  // To delete a signing certificate for an IAM user
   884  //
   885  // The following command deletes the specified signing certificate for the IAM user
   886  // named Anika.
   887  func ExampleIAM_DeleteSigningCertificate_shared00() {
   888  	svc := iam.New(session.New())
   889  	input := &iam.DeleteSigningCertificateInput{
   890  		CertificateId: aws.String("TA7SMP42TDN5Z26OBPJE7EXAMPLE"),
   891  		UserName:      aws.String("Anika"),
   892  	}
   893  
   894  	result, err := svc.DeleteSigningCertificate(input)
   895  	if err != nil {
   896  		if aerr, ok := err.(awserr.Error); ok {
   897  			switch aerr.Code() {
   898  			case iam.ErrCodeNoSuchEntityException:
   899  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   900  			case iam.ErrCodeLimitExceededException:
   901  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   902  			case iam.ErrCodeServiceFailureException:
   903  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   904  			default:
   905  				fmt.Println(aerr.Error())
   906  			}
   907  		} else {
   908  			// Print the error, cast err to awserr.Error to get the Code and
   909  			// Message from an error.
   910  			fmt.Println(err.Error())
   911  		}
   912  		return
   913  	}
   914  
   915  	fmt.Println(result)
   916  }
   917  
   918  // To delete an IAM user
   919  //
   920  // The following command removes the IAM user named Bob from the current account.
   921  func ExampleIAM_DeleteUser_shared00() {
   922  	svc := iam.New(session.New())
   923  	input := &iam.DeleteUserInput{
   924  		UserName: aws.String("Bob"),
   925  	}
   926  
   927  	result, err := svc.DeleteUser(input)
   928  	if err != nil {
   929  		if aerr, ok := err.(awserr.Error); ok {
   930  			switch aerr.Code() {
   931  			case iam.ErrCodeLimitExceededException:
   932  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   933  			case iam.ErrCodeNoSuchEntityException:
   934  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   935  			case iam.ErrCodeDeleteConflictException:
   936  				fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error())
   937  			case iam.ErrCodeConcurrentModificationException:
   938  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
   939  			case iam.ErrCodeServiceFailureException:
   940  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   941  			default:
   942  				fmt.Println(aerr.Error())
   943  			}
   944  		} else {
   945  			// Print the error, cast err to awserr.Error to get the Code and
   946  			// Message from an error.
   947  			fmt.Println(err.Error())
   948  		}
   949  		return
   950  	}
   951  
   952  	fmt.Println(result)
   953  }
   954  
   955  // To remove a policy from an IAM user
   956  //
   957  // The following delete-user-policy command removes the specified policy from the IAM
   958  // user named Juan:
   959  func ExampleIAM_DeleteUserPolicy_shared00() {
   960  	svc := iam.New(session.New())
   961  	input := &iam.DeleteUserPolicyInput{
   962  		PolicyName: aws.String("ExamplePolicy"),
   963  		UserName:   aws.String("Juan"),
   964  	}
   965  
   966  	result, err := svc.DeleteUserPolicy(input)
   967  	if err != nil {
   968  		if aerr, ok := err.(awserr.Error); ok {
   969  			switch aerr.Code() {
   970  			case iam.ErrCodeNoSuchEntityException:
   971  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
   972  			case iam.ErrCodeLimitExceededException:
   973  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
   974  			case iam.ErrCodeServiceFailureException:
   975  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
   976  			default:
   977  				fmt.Println(aerr.Error())
   978  			}
   979  		} else {
   980  			// Print the error, cast err to awserr.Error to get the Code and
   981  			// Message from an error.
   982  			fmt.Println(err.Error())
   983  		}
   984  		return
   985  	}
   986  
   987  	fmt.Println(result)
   988  }
   989  
   990  // To remove a virtual MFA device
   991  //
   992  // The following delete-virtual-mfa-device command removes the specified MFA device
   993  // from the current AWS account.
   994  func ExampleIAM_DeleteVirtualMFADevice_shared00() {
   995  	svc := iam.New(session.New())
   996  	input := &iam.DeleteVirtualMFADeviceInput{
   997  		SerialNumber: aws.String("arn:aws:iam::123456789012:mfa/ExampleName"),
   998  	}
   999  
  1000  	result, err := svc.DeleteVirtualMFADevice(input)
  1001  	if err != nil {
  1002  		if aerr, ok := err.(awserr.Error); ok {
  1003  			switch aerr.Code() {
  1004  			case iam.ErrCodeNoSuchEntityException:
  1005  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1006  			case iam.ErrCodeDeleteConflictException:
  1007  				fmt.Println(iam.ErrCodeDeleteConflictException, aerr.Error())
  1008  			case iam.ErrCodeLimitExceededException:
  1009  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1010  			case iam.ErrCodeServiceFailureException:
  1011  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1012  			default:
  1013  				fmt.Println(aerr.Error())
  1014  			}
  1015  		} else {
  1016  			// Print the error, cast err to awserr.Error to get the Code and
  1017  			// Message from an error.
  1018  			fmt.Println(err.Error())
  1019  		}
  1020  		return
  1021  	}
  1022  
  1023  	fmt.Println(result)
  1024  }
  1025  
  1026  // To generate a service last accessed data report for an organizational unit
  1027  //
  1028  // The following operation generates a report for the organizational unit ou-rge0-awexample
  1029  func ExampleIAM_GenerateOrganizationsAccessReport_shared00() {
  1030  	svc := iam.New(session.New())
  1031  	input := &iam.GenerateOrganizationsAccessReportInput{
  1032  		EntityPath: aws.String("o-a1b2c3d4e5/r-f6g7h8i9j0example/ou-1a2b3c-k9l8m7n6o5example"),
  1033  	}
  1034  
  1035  	result, err := svc.GenerateOrganizationsAccessReport(input)
  1036  	if err != nil {
  1037  		if aerr, ok := err.(awserr.Error); ok {
  1038  			switch aerr.Code() {
  1039  			case iam.ErrCodeReportGenerationLimitExceededException:
  1040  				fmt.Println(iam.ErrCodeReportGenerationLimitExceededException, aerr.Error())
  1041  			default:
  1042  				fmt.Println(aerr.Error())
  1043  			}
  1044  		} else {
  1045  			// Print the error, cast err to awserr.Error to get the Code and
  1046  			// Message from an error.
  1047  			fmt.Println(err.Error())
  1048  		}
  1049  		return
  1050  	}
  1051  
  1052  	fmt.Println(result)
  1053  }
  1054  
  1055  // To generate a service last accessed data report for a policy
  1056  //
  1057  // The following operation generates a report for the policy: ExamplePolicy1
  1058  func ExampleIAM_GenerateServiceLastAccessedDetails_shared00() {
  1059  	svc := iam.New(session.New())
  1060  	input := &iam.GenerateServiceLastAccessedDetailsInput{
  1061  		Arn: aws.String("arn:aws:iam::123456789012:policy/ExamplePolicy1"),
  1062  	}
  1063  
  1064  	result, err := svc.GenerateServiceLastAccessedDetails(input)
  1065  	if err != nil {
  1066  		if aerr, ok := err.(awserr.Error); ok {
  1067  			switch aerr.Code() {
  1068  			case iam.ErrCodeNoSuchEntityException:
  1069  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1070  			case iam.ErrCodeInvalidInputException:
  1071  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1072  			default:
  1073  				fmt.Println(aerr.Error())
  1074  			}
  1075  		} else {
  1076  			// Print the error, cast err to awserr.Error to get the Code and
  1077  			// Message from an error.
  1078  			fmt.Println(err.Error())
  1079  		}
  1080  		return
  1081  	}
  1082  
  1083  	fmt.Println(result)
  1084  }
  1085  
  1086  // To see the current account password policy
  1087  //
  1088  // The following command displays details about the password policy for the current
  1089  // AWS account.
  1090  func ExampleIAM_GetAccountPasswordPolicy_shared00() {
  1091  	svc := iam.New(session.New())
  1092  	input := &iam.GetAccountPasswordPolicyInput{}
  1093  
  1094  	result, err := svc.GetAccountPasswordPolicy(input)
  1095  	if err != nil {
  1096  		if aerr, ok := err.(awserr.Error); ok {
  1097  			switch aerr.Code() {
  1098  			case iam.ErrCodeNoSuchEntityException:
  1099  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1100  			case iam.ErrCodeServiceFailureException:
  1101  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1102  			default:
  1103  				fmt.Println(aerr.Error())
  1104  			}
  1105  		} else {
  1106  			// Print the error, cast err to awserr.Error to get the Code and
  1107  			// Message from an error.
  1108  			fmt.Println(err.Error())
  1109  		}
  1110  		return
  1111  	}
  1112  
  1113  	fmt.Println(result)
  1114  }
  1115  
  1116  // To get information about IAM entity quotas and usage in the current account
  1117  //
  1118  // The following command returns information about the IAM entity quotas and usage in
  1119  // the current AWS account.
  1120  func ExampleIAM_GetAccountSummary_shared00() {
  1121  	svc := iam.New(session.New())
  1122  	input := &iam.GetAccountSummaryInput{}
  1123  
  1124  	result, err := svc.GetAccountSummary(input)
  1125  	if err != nil {
  1126  		if aerr, ok := err.(awserr.Error); ok {
  1127  			switch aerr.Code() {
  1128  			case iam.ErrCodeServiceFailureException:
  1129  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1130  			default:
  1131  				fmt.Println(aerr.Error())
  1132  			}
  1133  		} else {
  1134  			// Print the error, cast err to awserr.Error to get the Code and
  1135  			// Message from an error.
  1136  			fmt.Println(err.Error())
  1137  		}
  1138  		return
  1139  	}
  1140  
  1141  	fmt.Println(result)
  1142  }
  1143  
  1144  // To get information about an instance profile
  1145  //
  1146  // The following command gets information about the instance profile named ExampleInstanceProfile.
  1147  func ExampleIAM_GetInstanceProfile_shared00() {
  1148  	svc := iam.New(session.New())
  1149  	input := &iam.GetInstanceProfileInput{
  1150  		InstanceProfileName: aws.String("ExampleInstanceProfile"),
  1151  	}
  1152  
  1153  	result, err := svc.GetInstanceProfile(input)
  1154  	if err != nil {
  1155  		if aerr, ok := err.(awserr.Error); ok {
  1156  			switch aerr.Code() {
  1157  			case iam.ErrCodeNoSuchEntityException:
  1158  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1159  			case iam.ErrCodeServiceFailureException:
  1160  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1161  			default:
  1162  				fmt.Println(aerr.Error())
  1163  			}
  1164  		} else {
  1165  			// Print the error, cast err to awserr.Error to get the Code and
  1166  			// Message from an error.
  1167  			fmt.Println(err.Error())
  1168  		}
  1169  		return
  1170  	}
  1171  
  1172  	fmt.Println(result)
  1173  }
  1174  
  1175  // To get password information for an IAM user
  1176  //
  1177  // The following command gets information about the password for the IAM user named
  1178  // Anika.
  1179  func ExampleIAM_GetLoginProfile_shared00() {
  1180  	svc := iam.New(session.New())
  1181  	input := &iam.GetLoginProfileInput{
  1182  		UserName: aws.String("Anika"),
  1183  	}
  1184  
  1185  	result, err := svc.GetLoginProfile(input)
  1186  	if err != nil {
  1187  		if aerr, ok := err.(awserr.Error); ok {
  1188  			switch aerr.Code() {
  1189  			case iam.ErrCodeNoSuchEntityException:
  1190  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1191  			case iam.ErrCodeServiceFailureException:
  1192  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1193  			default:
  1194  				fmt.Println(aerr.Error())
  1195  			}
  1196  		} else {
  1197  			// Print the error, cast err to awserr.Error to get the Code and
  1198  			// Message from an error.
  1199  			fmt.Println(err.Error())
  1200  		}
  1201  		return
  1202  	}
  1203  
  1204  	fmt.Println(result)
  1205  }
  1206  
  1207  // To get details from a previously generated organizational unit report
  1208  //
  1209  // The following operation gets details about the report with the job ID: examplea-1234-b567-cde8-90fg123abcd4
  1210  func ExampleIAM_GetOrganizationsAccessReport_shared00() {
  1211  	svc := iam.New(session.New())
  1212  	input := &iam.GetOrganizationsAccessReportInput{
  1213  		JobId: aws.String("examplea-1234-b567-cde8-90fg123abcd4"),
  1214  	}
  1215  
  1216  	result, err := svc.GetOrganizationsAccessReport(input)
  1217  	if err != nil {
  1218  		if aerr, ok := err.(awserr.Error); ok {
  1219  			switch aerr.Code() {
  1220  			case iam.ErrCodeNoSuchEntityException:
  1221  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1222  			default:
  1223  				fmt.Println(aerr.Error())
  1224  			}
  1225  		} else {
  1226  			// Print the error, cast err to awserr.Error to get the Code and
  1227  			// Message from an error.
  1228  			fmt.Println(err.Error())
  1229  		}
  1230  		return
  1231  	}
  1232  
  1233  	fmt.Println(result)
  1234  }
  1235  
  1236  // To get information about an IAM role
  1237  //
  1238  // The following command gets information about the role named Test-Role.
  1239  func ExampleIAM_GetRole_shared00() {
  1240  	svc := iam.New(session.New())
  1241  	input := &iam.GetRoleInput{
  1242  		RoleName: aws.String("Test-Role"),
  1243  	}
  1244  
  1245  	result, err := svc.GetRole(input)
  1246  	if err != nil {
  1247  		if aerr, ok := err.(awserr.Error); ok {
  1248  			switch aerr.Code() {
  1249  			case iam.ErrCodeNoSuchEntityException:
  1250  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1251  			case iam.ErrCodeServiceFailureException:
  1252  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1253  			default:
  1254  				fmt.Println(aerr.Error())
  1255  			}
  1256  		} else {
  1257  			// Print the error, cast err to awserr.Error to get the Code and
  1258  			// Message from an error.
  1259  			fmt.Println(err.Error())
  1260  		}
  1261  		return
  1262  	}
  1263  
  1264  	fmt.Println(result)
  1265  }
  1266  
  1267  // To get details from a previously-generated report
  1268  //
  1269  // The following operation gets details about the report with the job ID: examplef-1305-c245-eba4-71fe298bcda7
  1270  func ExampleIAM_GetServiceLastAccessedDetails_shared00() {
  1271  	svc := iam.New(session.New())
  1272  	input := &iam.GetServiceLastAccessedDetailsInput{
  1273  		JobId: aws.String("examplef-1305-c245-eba4-71fe298bcda7"),
  1274  	}
  1275  
  1276  	result, err := svc.GetServiceLastAccessedDetails(input)
  1277  	if err != nil {
  1278  		if aerr, ok := err.(awserr.Error); ok {
  1279  			switch aerr.Code() {
  1280  			case iam.ErrCodeNoSuchEntityException:
  1281  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1282  			case iam.ErrCodeInvalidInputException:
  1283  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1284  			default:
  1285  				fmt.Println(aerr.Error())
  1286  			}
  1287  		} else {
  1288  			// Print the error, cast err to awserr.Error to get the Code and
  1289  			// Message from an error.
  1290  			fmt.Println(err.Error())
  1291  		}
  1292  		return
  1293  	}
  1294  
  1295  	fmt.Println(result)
  1296  }
  1297  
  1298  // To get sntity details from a previously-generated report
  1299  //
  1300  // The following operation returns details about the entities that attempted to access
  1301  // the IAM service.
  1302  func ExampleIAM_GetServiceLastAccessedDetailsWithEntities_shared00() {
  1303  	svc := iam.New(session.New())
  1304  	input := &iam.GetServiceLastAccessedDetailsWithEntitiesInput{
  1305  		JobId:            aws.String("examplef-1305-c245-eba4-71fe298bcda7"),
  1306  		ServiceNamespace: aws.String("iam"),
  1307  	}
  1308  
  1309  	result, err := svc.GetServiceLastAccessedDetailsWithEntities(input)
  1310  	if err != nil {
  1311  		if aerr, ok := err.(awserr.Error); ok {
  1312  			switch aerr.Code() {
  1313  			case iam.ErrCodeNoSuchEntityException:
  1314  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1315  			case iam.ErrCodeInvalidInputException:
  1316  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1317  			default:
  1318  				fmt.Println(aerr.Error())
  1319  			}
  1320  		} else {
  1321  			// Print the error, cast err to awserr.Error to get the Code and
  1322  			// Message from an error.
  1323  			fmt.Println(err.Error())
  1324  		}
  1325  		return
  1326  	}
  1327  
  1328  	fmt.Println(result)
  1329  }
  1330  
  1331  // To get information about an IAM user
  1332  //
  1333  // The following command gets information about the IAM user named Bob.
  1334  func ExampleIAM_GetUser_shared00() {
  1335  	svc := iam.New(session.New())
  1336  	input := &iam.GetUserInput{
  1337  		UserName: aws.String("Bob"),
  1338  	}
  1339  
  1340  	result, err := svc.GetUser(input)
  1341  	if err != nil {
  1342  		if aerr, ok := err.(awserr.Error); ok {
  1343  			switch aerr.Code() {
  1344  			case iam.ErrCodeNoSuchEntityException:
  1345  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1346  			case iam.ErrCodeServiceFailureException:
  1347  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1348  			default:
  1349  				fmt.Println(aerr.Error())
  1350  			}
  1351  		} else {
  1352  			// Print the error, cast err to awserr.Error to get the Code and
  1353  			// Message from an error.
  1354  			fmt.Println(err.Error())
  1355  		}
  1356  		return
  1357  	}
  1358  
  1359  	fmt.Println(result)
  1360  }
  1361  
  1362  // To list the access key IDs for an IAM user
  1363  //
  1364  // The following command lists the access keys IDs for the IAM user named Alice.
  1365  func ExampleIAM_ListAccessKeys_shared00() {
  1366  	svc := iam.New(session.New())
  1367  	input := &iam.ListAccessKeysInput{
  1368  		UserName: aws.String("Alice"),
  1369  	}
  1370  
  1371  	result, err := svc.ListAccessKeys(input)
  1372  	if err != nil {
  1373  		if aerr, ok := err.(awserr.Error); ok {
  1374  			switch aerr.Code() {
  1375  			case iam.ErrCodeNoSuchEntityException:
  1376  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1377  			case iam.ErrCodeServiceFailureException:
  1378  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1379  			default:
  1380  				fmt.Println(aerr.Error())
  1381  			}
  1382  		} else {
  1383  			// Print the error, cast err to awserr.Error to get the Code and
  1384  			// Message from an error.
  1385  			fmt.Println(err.Error())
  1386  		}
  1387  		return
  1388  	}
  1389  
  1390  	fmt.Println(result)
  1391  }
  1392  
  1393  // To list account aliases
  1394  //
  1395  // The following command lists the aliases for the current account.
  1396  func ExampleIAM_ListAccountAliases_shared00() {
  1397  	svc := iam.New(session.New())
  1398  	input := &iam.ListAccountAliasesInput{}
  1399  
  1400  	result, err := svc.ListAccountAliases(input)
  1401  	if err != nil {
  1402  		if aerr, ok := err.(awserr.Error); ok {
  1403  			switch aerr.Code() {
  1404  			case iam.ErrCodeServiceFailureException:
  1405  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1406  			default:
  1407  				fmt.Println(aerr.Error())
  1408  			}
  1409  		} else {
  1410  			// Print the error, cast err to awserr.Error to get the Code and
  1411  			// Message from an error.
  1412  			fmt.Println(err.Error())
  1413  		}
  1414  		return
  1415  	}
  1416  
  1417  	fmt.Println(result)
  1418  }
  1419  
  1420  // To list the in-line policies for an IAM group
  1421  //
  1422  // The following command lists the names of in-line policies that are embedded in the
  1423  // IAM group named Admins.
  1424  func ExampleIAM_ListGroupPolicies_shared00() {
  1425  	svc := iam.New(session.New())
  1426  	input := &iam.ListGroupPoliciesInput{
  1427  		GroupName: aws.String("Admins"),
  1428  	}
  1429  
  1430  	result, err := svc.ListGroupPolicies(input)
  1431  	if err != nil {
  1432  		if aerr, ok := err.(awserr.Error); ok {
  1433  			switch aerr.Code() {
  1434  			case iam.ErrCodeNoSuchEntityException:
  1435  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1436  			case iam.ErrCodeServiceFailureException:
  1437  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1438  			default:
  1439  				fmt.Println(aerr.Error())
  1440  			}
  1441  		} else {
  1442  			// Print the error, cast err to awserr.Error to get the Code and
  1443  			// Message from an error.
  1444  			fmt.Println(err.Error())
  1445  		}
  1446  		return
  1447  	}
  1448  
  1449  	fmt.Println(result)
  1450  }
  1451  
  1452  // To list the IAM groups for the current account
  1453  //
  1454  // The following command lists the IAM groups in the current account:
  1455  func ExampleIAM_ListGroups_shared00() {
  1456  	svc := iam.New(session.New())
  1457  	input := &iam.ListGroupsInput{}
  1458  
  1459  	result, err := svc.ListGroups(input)
  1460  	if err != nil {
  1461  		if aerr, ok := err.(awserr.Error); ok {
  1462  			switch aerr.Code() {
  1463  			case iam.ErrCodeServiceFailureException:
  1464  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1465  			default:
  1466  				fmt.Println(aerr.Error())
  1467  			}
  1468  		} else {
  1469  			// Print the error, cast err to awserr.Error to get the Code and
  1470  			// Message from an error.
  1471  			fmt.Println(err.Error())
  1472  		}
  1473  		return
  1474  	}
  1475  
  1476  	fmt.Println(result)
  1477  }
  1478  
  1479  // To list the groups that an IAM user belongs to
  1480  //
  1481  // The following command displays the groups that the IAM user named Bob belongs to.
  1482  func ExampleIAM_ListGroupsForUser_shared00() {
  1483  	svc := iam.New(session.New())
  1484  	input := &iam.ListGroupsForUserInput{
  1485  		UserName: aws.String("Bob"),
  1486  	}
  1487  
  1488  	result, err := svc.ListGroupsForUser(input)
  1489  	if err != nil {
  1490  		if aerr, ok := err.(awserr.Error); ok {
  1491  			switch aerr.Code() {
  1492  			case iam.ErrCodeNoSuchEntityException:
  1493  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1494  			case iam.ErrCodeServiceFailureException:
  1495  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1496  			default:
  1497  				fmt.Println(aerr.Error())
  1498  			}
  1499  		} else {
  1500  			// Print the error, cast err to awserr.Error to get the Code and
  1501  			// Message from an error.
  1502  			fmt.Println(err.Error())
  1503  		}
  1504  		return
  1505  	}
  1506  
  1507  	fmt.Println(result)
  1508  }
  1509  
  1510  // To list policies that allow access to a service
  1511  //
  1512  // The following operation lists policies that allow ExampleUser01 to access IAM or
  1513  // EC2.
  1514  func ExampleIAM_ListPoliciesGrantingServiceAccess_shared00() {
  1515  	svc := iam.New(session.New())
  1516  	input := &iam.ListPoliciesGrantingServiceAccessInput{
  1517  		Arn: aws.String("arn:aws:iam::123456789012:user/ExampleUser01"),
  1518  		ServiceNamespaces: []*string{
  1519  			aws.String("iam"),
  1520  			aws.String("ec2"),
  1521  		},
  1522  	}
  1523  
  1524  	result, err := svc.ListPoliciesGrantingServiceAccess(input)
  1525  	if err != nil {
  1526  		if aerr, ok := err.(awserr.Error); ok {
  1527  			switch aerr.Code() {
  1528  			case iam.ErrCodeNoSuchEntityException:
  1529  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1530  			case iam.ErrCodeInvalidInputException:
  1531  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1532  			default:
  1533  				fmt.Println(aerr.Error())
  1534  			}
  1535  		} else {
  1536  			// Print the error, cast err to awserr.Error to get the Code and
  1537  			// Message from an error.
  1538  			fmt.Println(err.Error())
  1539  		}
  1540  		return
  1541  	}
  1542  
  1543  	fmt.Println(result)
  1544  }
  1545  
  1546  // To list the tags attached to an IAM role
  1547  //
  1548  // The following example shows how to list the tags attached to a role.
  1549  func ExampleIAM_ListRoleTags_shared00() {
  1550  	svc := iam.New(session.New())
  1551  	input := &iam.ListRoleTagsInput{
  1552  		RoleName: aws.String("taggedrole1"),
  1553  	}
  1554  
  1555  	result, err := svc.ListRoleTags(input)
  1556  	if err != nil {
  1557  		if aerr, ok := err.(awserr.Error); ok {
  1558  			switch aerr.Code() {
  1559  			case iam.ErrCodeNoSuchEntityException:
  1560  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1561  			case iam.ErrCodeServiceFailureException:
  1562  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1563  			default:
  1564  				fmt.Println(aerr.Error())
  1565  			}
  1566  		} else {
  1567  			// Print the error, cast err to awserr.Error to get the Code and
  1568  			// Message from an error.
  1569  			fmt.Println(err.Error())
  1570  		}
  1571  		return
  1572  	}
  1573  
  1574  	fmt.Println(result)
  1575  }
  1576  
  1577  // To list the signing certificates for an IAM user
  1578  //
  1579  // The following command lists the signing certificates for the IAM user named Bob.
  1580  func ExampleIAM_ListSigningCertificates_shared00() {
  1581  	svc := iam.New(session.New())
  1582  	input := &iam.ListSigningCertificatesInput{
  1583  		UserName: aws.String("Bob"),
  1584  	}
  1585  
  1586  	result, err := svc.ListSigningCertificates(input)
  1587  	if err != nil {
  1588  		if aerr, ok := err.(awserr.Error); ok {
  1589  			switch aerr.Code() {
  1590  			case iam.ErrCodeNoSuchEntityException:
  1591  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1592  			case iam.ErrCodeServiceFailureException:
  1593  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1594  			default:
  1595  				fmt.Println(aerr.Error())
  1596  			}
  1597  		} else {
  1598  			// Print the error, cast err to awserr.Error to get the Code and
  1599  			// Message from an error.
  1600  			fmt.Println(err.Error())
  1601  		}
  1602  		return
  1603  	}
  1604  
  1605  	fmt.Println(result)
  1606  }
  1607  
  1608  // To list the tags attached to an IAM user
  1609  //
  1610  // The following example shows how to list the tags attached to a user.
  1611  func ExampleIAM_ListUserTags_shared00() {
  1612  	svc := iam.New(session.New())
  1613  	input := &iam.ListUserTagsInput{
  1614  		UserName: aws.String("anika"),
  1615  	}
  1616  
  1617  	result, err := svc.ListUserTags(input)
  1618  	if err != nil {
  1619  		if aerr, ok := err.(awserr.Error); ok {
  1620  			switch aerr.Code() {
  1621  			case iam.ErrCodeNoSuchEntityException:
  1622  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1623  			case iam.ErrCodeServiceFailureException:
  1624  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1625  			default:
  1626  				fmt.Println(aerr.Error())
  1627  			}
  1628  		} else {
  1629  			// Print the error, cast err to awserr.Error to get the Code and
  1630  			// Message from an error.
  1631  			fmt.Println(err.Error())
  1632  		}
  1633  		return
  1634  	}
  1635  
  1636  	fmt.Println(result)
  1637  }
  1638  
  1639  // To list IAM users
  1640  //
  1641  // The following command lists the IAM users in the current account.
  1642  func ExampleIAM_ListUsers_shared00() {
  1643  	svc := iam.New(session.New())
  1644  	input := &iam.ListUsersInput{}
  1645  
  1646  	result, err := svc.ListUsers(input)
  1647  	if err != nil {
  1648  		if aerr, ok := err.(awserr.Error); ok {
  1649  			switch aerr.Code() {
  1650  			case iam.ErrCodeServiceFailureException:
  1651  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1652  			default:
  1653  				fmt.Println(aerr.Error())
  1654  			}
  1655  		} else {
  1656  			// Print the error, cast err to awserr.Error to get the Code and
  1657  			// Message from an error.
  1658  			fmt.Println(err.Error())
  1659  		}
  1660  		return
  1661  	}
  1662  
  1663  	fmt.Println(result)
  1664  }
  1665  
  1666  // To list virtual MFA devices
  1667  //
  1668  // The following command lists the virtual MFA devices that have been configured for
  1669  // the current account.
  1670  func ExampleIAM_ListVirtualMFADevices_shared00() {
  1671  	svc := iam.New(session.New())
  1672  	input := &iam.ListVirtualMFADevicesInput{}
  1673  
  1674  	result, err := svc.ListVirtualMFADevices(input)
  1675  	if err != nil {
  1676  		if aerr, ok := err.(awserr.Error); ok {
  1677  			switch aerr.Code() {
  1678  			default:
  1679  				fmt.Println(aerr.Error())
  1680  			}
  1681  		} else {
  1682  			// Print the error, cast err to awserr.Error to get the Code and
  1683  			// Message from an error.
  1684  			fmt.Println(err.Error())
  1685  		}
  1686  		return
  1687  	}
  1688  
  1689  	fmt.Println(result)
  1690  }
  1691  
  1692  // To add a policy to a group
  1693  //
  1694  // The following command adds a policy named AllPerms to the IAM group named Admins.
  1695  func ExampleIAM_PutGroupPolicy_shared00() {
  1696  	svc := iam.New(session.New())
  1697  	input := &iam.PutGroupPolicyInput{
  1698  		GroupName:      aws.String("Admins"),
  1699  		PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}"),
  1700  		PolicyName:     aws.String("AllPerms"),
  1701  	}
  1702  
  1703  	result, err := svc.PutGroupPolicy(input)
  1704  	if err != nil {
  1705  		if aerr, ok := err.(awserr.Error); ok {
  1706  			switch aerr.Code() {
  1707  			case iam.ErrCodeLimitExceededException:
  1708  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1709  			case iam.ErrCodeMalformedPolicyDocumentException:
  1710  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
  1711  			case iam.ErrCodeNoSuchEntityException:
  1712  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1713  			case iam.ErrCodeServiceFailureException:
  1714  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1715  			default:
  1716  				fmt.Println(aerr.Error())
  1717  			}
  1718  		} else {
  1719  			// Print the error, cast err to awserr.Error to get the Code and
  1720  			// Message from an error.
  1721  			fmt.Println(err.Error())
  1722  		}
  1723  		return
  1724  	}
  1725  
  1726  	fmt.Println(result)
  1727  }
  1728  
  1729  // To attach a permissions policy to an IAM role
  1730  //
  1731  // The following command adds a permissions policy to the role named Test-Role.
  1732  func ExampleIAM_PutRolePolicy_shared00() {
  1733  	svc := iam.New(session.New())
  1734  	input := &iam.PutRolePolicyInput{
  1735  		PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}}"),
  1736  		PolicyName:     aws.String("S3AccessPolicy"),
  1737  		RoleName:       aws.String("S3Access"),
  1738  	}
  1739  
  1740  	result, err := svc.PutRolePolicy(input)
  1741  	if err != nil {
  1742  		if aerr, ok := err.(awserr.Error); ok {
  1743  			switch aerr.Code() {
  1744  			case iam.ErrCodeLimitExceededException:
  1745  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1746  			case iam.ErrCodeMalformedPolicyDocumentException:
  1747  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
  1748  			case iam.ErrCodeNoSuchEntityException:
  1749  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1750  			case iam.ErrCodeUnmodifiableEntityException:
  1751  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
  1752  			case iam.ErrCodeServiceFailureException:
  1753  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1754  			default:
  1755  				fmt.Println(aerr.Error())
  1756  			}
  1757  		} else {
  1758  			// Print the error, cast err to awserr.Error to get the Code and
  1759  			// Message from an error.
  1760  			fmt.Println(err.Error())
  1761  		}
  1762  		return
  1763  	}
  1764  
  1765  	fmt.Println(result)
  1766  }
  1767  
  1768  // To attach a policy to an IAM user
  1769  //
  1770  // The following command attaches a policy to the IAM user named Bob.
  1771  func ExampleIAM_PutUserPolicy_shared00() {
  1772  	svc := iam.New(session.New())
  1773  	input := &iam.PutUserPolicyInput{
  1774  		PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}"),
  1775  		PolicyName:     aws.String("AllAccessPolicy"),
  1776  		UserName:       aws.String("Bob"),
  1777  	}
  1778  
  1779  	result, err := svc.PutUserPolicy(input)
  1780  	if err != nil {
  1781  		if aerr, ok := err.(awserr.Error); ok {
  1782  			switch aerr.Code() {
  1783  			case iam.ErrCodeLimitExceededException:
  1784  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1785  			case iam.ErrCodeMalformedPolicyDocumentException:
  1786  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
  1787  			case iam.ErrCodeNoSuchEntityException:
  1788  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1789  			case iam.ErrCodeServiceFailureException:
  1790  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1791  			default:
  1792  				fmt.Println(aerr.Error())
  1793  			}
  1794  		} else {
  1795  			// Print the error, cast err to awserr.Error to get the Code and
  1796  			// Message from an error.
  1797  			fmt.Println(err.Error())
  1798  		}
  1799  		return
  1800  	}
  1801  
  1802  	fmt.Println(result)
  1803  }
  1804  
  1805  // To remove a role from an instance profile
  1806  //
  1807  // The following command removes the role named Test-Role from the instance profile
  1808  // named ExampleInstanceProfile.
  1809  func ExampleIAM_RemoveRoleFromInstanceProfile_shared00() {
  1810  	svc := iam.New(session.New())
  1811  	input := &iam.RemoveRoleFromInstanceProfileInput{
  1812  		InstanceProfileName: aws.String("ExampleInstanceProfile"),
  1813  		RoleName:            aws.String("Test-Role"),
  1814  	}
  1815  
  1816  	result, err := svc.RemoveRoleFromInstanceProfile(input)
  1817  	if err != nil {
  1818  		if aerr, ok := err.(awserr.Error); ok {
  1819  			switch aerr.Code() {
  1820  			case iam.ErrCodeNoSuchEntityException:
  1821  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1822  			case iam.ErrCodeLimitExceededException:
  1823  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1824  			case iam.ErrCodeUnmodifiableEntityException:
  1825  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
  1826  			case iam.ErrCodeServiceFailureException:
  1827  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1828  			default:
  1829  				fmt.Println(aerr.Error())
  1830  			}
  1831  		} else {
  1832  			// Print the error, cast err to awserr.Error to get the Code and
  1833  			// Message from an error.
  1834  			fmt.Println(err.Error())
  1835  		}
  1836  		return
  1837  	}
  1838  
  1839  	fmt.Println(result)
  1840  }
  1841  
  1842  // To remove a user from an IAM group
  1843  //
  1844  // The following command removes the user named Bob from the IAM group named Admins.
  1845  func ExampleIAM_RemoveUserFromGroup_shared00() {
  1846  	svc := iam.New(session.New())
  1847  	input := &iam.RemoveUserFromGroupInput{
  1848  		GroupName: aws.String("Admins"),
  1849  		UserName:  aws.String("Bob"),
  1850  	}
  1851  
  1852  	result, err := svc.RemoveUserFromGroup(input)
  1853  	if err != nil {
  1854  		if aerr, ok := err.(awserr.Error); ok {
  1855  			switch aerr.Code() {
  1856  			case iam.ErrCodeNoSuchEntityException:
  1857  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1858  			case iam.ErrCodeLimitExceededException:
  1859  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1860  			case iam.ErrCodeServiceFailureException:
  1861  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1862  			default:
  1863  				fmt.Println(aerr.Error())
  1864  			}
  1865  		} else {
  1866  			// Print the error, cast err to awserr.Error to get the Code and
  1867  			// Message from an error.
  1868  			fmt.Println(err.Error())
  1869  		}
  1870  		return
  1871  	}
  1872  
  1873  	fmt.Println(result)
  1874  }
  1875  
  1876  // To delete an access key for an IAM user
  1877  //
  1878  // The following command sets the STS global endpoint token to version 2. Version 2
  1879  // tokens are valid in all Regions.
  1880  func ExampleIAM_SetSecurityTokenServicePreferences_shared00() {
  1881  	svc := iam.New(session.New())
  1882  	input := &iam.SetSecurityTokenServicePreferencesInput{
  1883  		GlobalEndpointTokenVersion: aws.String("v2Token"),
  1884  	}
  1885  
  1886  	result, err := svc.SetSecurityTokenServicePreferences(input)
  1887  	if err != nil {
  1888  		if aerr, ok := err.(awserr.Error); ok {
  1889  			switch aerr.Code() {
  1890  			case iam.ErrCodeServiceFailureException:
  1891  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1892  			default:
  1893  				fmt.Println(aerr.Error())
  1894  			}
  1895  		} else {
  1896  			// Print the error, cast err to awserr.Error to get the Code and
  1897  			// Message from an error.
  1898  			fmt.Println(err.Error())
  1899  		}
  1900  		return
  1901  	}
  1902  
  1903  	fmt.Println(result)
  1904  }
  1905  
  1906  // To add a tag key and value to an IAM role
  1907  //
  1908  // The following example shows how to add tags to an existing role.
  1909  func ExampleIAM_TagRole_shared00() {
  1910  	svc := iam.New(session.New())
  1911  	input := &iam.TagRoleInput{
  1912  		RoleName: aws.String("taggedrole"),
  1913  		Tags: []*iam.Tag{
  1914  			{
  1915  				Key:   aws.String("Dept"),
  1916  				Value: aws.String("Accounting"),
  1917  			},
  1918  			{
  1919  				Key:   aws.String("CostCenter"),
  1920  				Value: aws.String("12345"),
  1921  			},
  1922  		},
  1923  	}
  1924  
  1925  	result, err := svc.TagRole(input)
  1926  	if err != nil {
  1927  		if aerr, ok := err.(awserr.Error); ok {
  1928  			switch aerr.Code() {
  1929  			case iam.ErrCodeNoSuchEntityException:
  1930  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1931  			case iam.ErrCodeLimitExceededException:
  1932  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1933  			case iam.ErrCodeInvalidInputException:
  1934  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1935  			case iam.ErrCodeConcurrentModificationException:
  1936  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  1937  			case iam.ErrCodeServiceFailureException:
  1938  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1939  			default:
  1940  				fmt.Println(aerr.Error())
  1941  			}
  1942  		} else {
  1943  			// Print the error, cast err to awserr.Error to get the Code and
  1944  			// Message from an error.
  1945  			fmt.Println(err.Error())
  1946  		}
  1947  		return
  1948  	}
  1949  
  1950  	fmt.Println(result)
  1951  }
  1952  
  1953  // To add a tag key and value to an IAM user
  1954  //
  1955  // The following example shows how to add tags to an existing user.
  1956  func ExampleIAM_TagUser_shared00() {
  1957  	svc := iam.New(session.New())
  1958  	input := &iam.TagUserInput{
  1959  		Tags: []*iam.Tag{
  1960  			{
  1961  				Key:   aws.String("Dept"),
  1962  				Value: aws.String("Accounting"),
  1963  			},
  1964  			{
  1965  				Key:   aws.String("CostCenter"),
  1966  				Value: aws.String("12345"),
  1967  			},
  1968  		},
  1969  		UserName: aws.String("anika"),
  1970  	}
  1971  
  1972  	result, err := svc.TagUser(input)
  1973  	if err != nil {
  1974  		if aerr, ok := err.(awserr.Error); ok {
  1975  			switch aerr.Code() {
  1976  			case iam.ErrCodeNoSuchEntityException:
  1977  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  1978  			case iam.ErrCodeLimitExceededException:
  1979  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  1980  			case iam.ErrCodeInvalidInputException:
  1981  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  1982  			case iam.ErrCodeConcurrentModificationException:
  1983  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  1984  			case iam.ErrCodeServiceFailureException:
  1985  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  1986  			default:
  1987  				fmt.Println(aerr.Error())
  1988  			}
  1989  		} else {
  1990  			// Print the error, cast err to awserr.Error to get the Code and
  1991  			// Message from an error.
  1992  			fmt.Println(err.Error())
  1993  		}
  1994  		return
  1995  	}
  1996  
  1997  	fmt.Println(result)
  1998  }
  1999  
  2000  // To remove a tag from an IAM role
  2001  //
  2002  // The following example shows how to remove a tag with the key 'Dept' from a role named
  2003  // 'taggedrole'.
  2004  func ExampleIAM_UntagRole_shared00() {
  2005  	svc := iam.New(session.New())
  2006  	input := &iam.UntagRoleInput{
  2007  		RoleName: aws.String("taggedrole"),
  2008  		TagKeys: []*string{
  2009  			aws.String("Dept"),
  2010  		},
  2011  	}
  2012  
  2013  	result, err := svc.UntagRole(input)
  2014  	if err != nil {
  2015  		if aerr, ok := err.(awserr.Error); ok {
  2016  			switch aerr.Code() {
  2017  			case iam.ErrCodeNoSuchEntityException:
  2018  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2019  			case iam.ErrCodeConcurrentModificationException:
  2020  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  2021  			case iam.ErrCodeServiceFailureException:
  2022  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2023  			default:
  2024  				fmt.Println(aerr.Error())
  2025  			}
  2026  		} else {
  2027  			// Print the error, cast err to awserr.Error to get the Code and
  2028  			// Message from an error.
  2029  			fmt.Println(err.Error())
  2030  		}
  2031  		return
  2032  	}
  2033  
  2034  	fmt.Println(result)
  2035  }
  2036  
  2037  // To remove a tag from an IAM user
  2038  //
  2039  // The following example shows how to remove tags that are attached to a user named
  2040  // 'anika'.
  2041  func ExampleIAM_UntagUser_shared00() {
  2042  	svc := iam.New(session.New())
  2043  	input := &iam.UntagUserInput{
  2044  		TagKeys: []*string{
  2045  			aws.String("Dept"),
  2046  		},
  2047  		UserName: aws.String("anika"),
  2048  	}
  2049  
  2050  	result, err := svc.UntagUser(input)
  2051  	if err != nil {
  2052  		if aerr, ok := err.(awserr.Error); ok {
  2053  			switch aerr.Code() {
  2054  			case iam.ErrCodeNoSuchEntityException:
  2055  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2056  			case iam.ErrCodeConcurrentModificationException:
  2057  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  2058  			case iam.ErrCodeServiceFailureException:
  2059  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2060  			default:
  2061  				fmt.Println(aerr.Error())
  2062  			}
  2063  		} else {
  2064  			// Print the error, cast err to awserr.Error to get the Code and
  2065  			// Message from an error.
  2066  			fmt.Println(err.Error())
  2067  		}
  2068  		return
  2069  	}
  2070  
  2071  	fmt.Println(result)
  2072  }
  2073  
  2074  // To activate or deactivate an access key for an IAM user
  2075  //
  2076  // The following command deactivates the specified access key (access key ID and secret
  2077  // access key) for the IAM user named Bob.
  2078  func ExampleIAM_UpdateAccessKey_shared00() {
  2079  	svc := iam.New(session.New())
  2080  	input := &iam.UpdateAccessKeyInput{
  2081  		AccessKeyId: aws.String("AKIAIOSFODNN7EXAMPLE"),
  2082  		Status:      aws.String("Inactive"),
  2083  		UserName:    aws.String("Bob"),
  2084  	}
  2085  
  2086  	result, err := svc.UpdateAccessKey(input)
  2087  	if err != nil {
  2088  		if aerr, ok := err.(awserr.Error); ok {
  2089  			switch aerr.Code() {
  2090  			case iam.ErrCodeNoSuchEntityException:
  2091  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2092  			case iam.ErrCodeLimitExceededException:
  2093  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2094  			case iam.ErrCodeServiceFailureException:
  2095  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2096  			default:
  2097  				fmt.Println(aerr.Error())
  2098  			}
  2099  		} else {
  2100  			// Print the error, cast err to awserr.Error to get the Code and
  2101  			// Message from an error.
  2102  			fmt.Println(err.Error())
  2103  		}
  2104  		return
  2105  	}
  2106  
  2107  	fmt.Println(result)
  2108  }
  2109  
  2110  // To set or change the current account password policy
  2111  //
  2112  // The following command sets the password policy to require a minimum length of eight
  2113  // characters and to require one or more numbers in the password:
  2114  func ExampleIAM_UpdateAccountPasswordPolicy_shared00() {
  2115  	svc := iam.New(session.New())
  2116  	input := &iam.UpdateAccountPasswordPolicyInput{
  2117  		MinimumPasswordLength: aws.Int64(8),
  2118  		RequireNumbers:        aws.Bool(true),
  2119  	}
  2120  
  2121  	result, err := svc.UpdateAccountPasswordPolicy(input)
  2122  	if err != nil {
  2123  		if aerr, ok := err.(awserr.Error); ok {
  2124  			switch aerr.Code() {
  2125  			case iam.ErrCodeNoSuchEntityException:
  2126  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2127  			case iam.ErrCodeMalformedPolicyDocumentException:
  2128  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
  2129  			case iam.ErrCodeLimitExceededException:
  2130  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2131  			case iam.ErrCodeServiceFailureException:
  2132  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2133  			default:
  2134  				fmt.Println(aerr.Error())
  2135  			}
  2136  		} else {
  2137  			// Print the error, cast err to awserr.Error to get the Code and
  2138  			// Message from an error.
  2139  			fmt.Println(err.Error())
  2140  		}
  2141  		return
  2142  	}
  2143  
  2144  	fmt.Println(result)
  2145  }
  2146  
  2147  // To update the trust policy for an IAM role
  2148  //
  2149  // The following command updates the role trust policy for the role named Test-Role:
  2150  func ExampleIAM_UpdateAssumeRolePolicy_shared00() {
  2151  	svc := iam.New(session.New())
  2152  	input := &iam.UpdateAssumeRolePolicyInput{
  2153  		PolicyDocument: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}"),
  2154  		RoleName:       aws.String("S3AccessForEC2Instances"),
  2155  	}
  2156  
  2157  	result, err := svc.UpdateAssumeRolePolicy(input)
  2158  	if err != nil {
  2159  		if aerr, ok := err.(awserr.Error); ok {
  2160  			switch aerr.Code() {
  2161  			case iam.ErrCodeNoSuchEntityException:
  2162  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2163  			case iam.ErrCodeMalformedPolicyDocumentException:
  2164  				fmt.Println(iam.ErrCodeMalformedPolicyDocumentException, aerr.Error())
  2165  			case iam.ErrCodeLimitExceededException:
  2166  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2167  			case iam.ErrCodeUnmodifiableEntityException:
  2168  				fmt.Println(iam.ErrCodeUnmodifiableEntityException, aerr.Error())
  2169  			case iam.ErrCodeServiceFailureException:
  2170  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2171  			default:
  2172  				fmt.Println(aerr.Error())
  2173  			}
  2174  		} else {
  2175  			// Print the error, cast err to awserr.Error to get the Code and
  2176  			// Message from an error.
  2177  			fmt.Println(err.Error())
  2178  		}
  2179  		return
  2180  	}
  2181  
  2182  	fmt.Println(result)
  2183  }
  2184  
  2185  // To rename an IAM group
  2186  //
  2187  // The following command changes the name of the IAM group Test to Test-1.
  2188  func ExampleIAM_UpdateGroup_shared00() {
  2189  	svc := iam.New(session.New())
  2190  	input := &iam.UpdateGroupInput{
  2191  		GroupName:    aws.String("Test"),
  2192  		NewGroupName: aws.String("Test-1"),
  2193  	}
  2194  
  2195  	result, err := svc.UpdateGroup(input)
  2196  	if err != nil {
  2197  		if aerr, ok := err.(awserr.Error); ok {
  2198  			switch aerr.Code() {
  2199  			case iam.ErrCodeNoSuchEntityException:
  2200  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2201  			case iam.ErrCodeEntityAlreadyExistsException:
  2202  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
  2203  			case iam.ErrCodeLimitExceededException:
  2204  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2205  			case iam.ErrCodeServiceFailureException:
  2206  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2207  			default:
  2208  				fmt.Println(aerr.Error())
  2209  			}
  2210  		} else {
  2211  			// Print the error, cast err to awserr.Error to get the Code and
  2212  			// Message from an error.
  2213  			fmt.Println(err.Error())
  2214  		}
  2215  		return
  2216  	}
  2217  
  2218  	fmt.Println(result)
  2219  }
  2220  
  2221  // To change the password for an IAM user
  2222  //
  2223  // The following command creates or changes the password for the IAM user named Bob.
  2224  func ExampleIAM_UpdateLoginProfile_shared00() {
  2225  	svc := iam.New(session.New())
  2226  	input := &iam.UpdateLoginProfileInput{
  2227  		Password: aws.String("SomeKindOfPassword123!@#"),
  2228  		UserName: aws.String("Bob"),
  2229  	}
  2230  
  2231  	result, err := svc.UpdateLoginProfile(input)
  2232  	if err != nil {
  2233  		if aerr, ok := err.(awserr.Error); ok {
  2234  			switch aerr.Code() {
  2235  			case iam.ErrCodeEntityTemporarilyUnmodifiableException:
  2236  				fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error())
  2237  			case iam.ErrCodeNoSuchEntityException:
  2238  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2239  			case iam.ErrCodePasswordPolicyViolationException:
  2240  				fmt.Println(iam.ErrCodePasswordPolicyViolationException, aerr.Error())
  2241  			case iam.ErrCodeLimitExceededException:
  2242  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2243  			case iam.ErrCodeServiceFailureException:
  2244  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2245  			default:
  2246  				fmt.Println(aerr.Error())
  2247  			}
  2248  		} else {
  2249  			// Print the error, cast err to awserr.Error to get the Code and
  2250  			// Message from an error.
  2251  			fmt.Println(err.Error())
  2252  		}
  2253  		return
  2254  	}
  2255  
  2256  	fmt.Println(result)
  2257  }
  2258  
  2259  // To change the active status of a signing certificate for an IAM user
  2260  //
  2261  // The following command changes the status of a signing certificate for a user named
  2262  // Bob to Inactive.
  2263  func ExampleIAM_UpdateSigningCertificate_shared00() {
  2264  	svc := iam.New(session.New())
  2265  	input := &iam.UpdateSigningCertificateInput{
  2266  		CertificateId: aws.String("TA7SMP42TDN5Z26OBPJE7EXAMPLE"),
  2267  		Status:        aws.String("Inactive"),
  2268  		UserName:      aws.String("Bob"),
  2269  	}
  2270  
  2271  	result, err := svc.UpdateSigningCertificate(input)
  2272  	if err != nil {
  2273  		if aerr, ok := err.(awserr.Error); ok {
  2274  			switch aerr.Code() {
  2275  			case iam.ErrCodeNoSuchEntityException:
  2276  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2277  			case iam.ErrCodeLimitExceededException:
  2278  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2279  			case iam.ErrCodeServiceFailureException:
  2280  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2281  			default:
  2282  				fmt.Println(aerr.Error())
  2283  			}
  2284  		} else {
  2285  			// Print the error, cast err to awserr.Error to get the Code and
  2286  			// Message from an error.
  2287  			fmt.Println(err.Error())
  2288  		}
  2289  		return
  2290  	}
  2291  
  2292  	fmt.Println(result)
  2293  }
  2294  
  2295  // To change an IAM user's name
  2296  //
  2297  // The following command changes the name of the IAM user Bob to Robert. It does not
  2298  // change the user's path.
  2299  func ExampleIAM_UpdateUser_shared00() {
  2300  	svc := iam.New(session.New())
  2301  	input := &iam.UpdateUserInput{
  2302  		NewUserName: aws.String("Robert"),
  2303  		UserName:    aws.String("Bob"),
  2304  	}
  2305  
  2306  	result, err := svc.UpdateUser(input)
  2307  	if err != nil {
  2308  		if aerr, ok := err.(awserr.Error); ok {
  2309  			switch aerr.Code() {
  2310  			case iam.ErrCodeNoSuchEntityException:
  2311  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2312  			case iam.ErrCodeLimitExceededException:
  2313  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2314  			case iam.ErrCodeEntityAlreadyExistsException:
  2315  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
  2316  			case iam.ErrCodeEntityTemporarilyUnmodifiableException:
  2317  				fmt.Println(iam.ErrCodeEntityTemporarilyUnmodifiableException, aerr.Error())
  2318  			case iam.ErrCodeConcurrentModificationException:
  2319  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  2320  			case iam.ErrCodeServiceFailureException:
  2321  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2322  			default:
  2323  				fmt.Println(aerr.Error())
  2324  			}
  2325  		} else {
  2326  			// Print the error, cast err to awserr.Error to get the Code and
  2327  			// Message from an error.
  2328  			fmt.Println(err.Error())
  2329  		}
  2330  		return
  2331  	}
  2332  
  2333  	fmt.Println(result)
  2334  }
  2335  
  2336  // To upload a server certificate to your AWS account
  2337  //
  2338  // The following upload-server-certificate command uploads a server certificate to your
  2339  // AWS account:
  2340  func ExampleIAM_UploadServerCertificate_shared00() {
  2341  	svc := iam.New(session.New())
  2342  	input := &iam.UploadServerCertificateInput{
  2343  		CertificateBody:       aws.String("-----BEGIN CERTIFICATE-----<a very long certificate text string>-----END CERTIFICATE-----"),
  2344  		Path:                  aws.String("/company/servercerts/"),
  2345  		PrivateKey:            aws.String("-----BEGIN DSA PRIVATE KEY-----<a very long private key string>-----END DSA PRIVATE KEY-----"),
  2346  		ServerCertificateName: aws.String("ProdServerCert"),
  2347  	}
  2348  
  2349  	result, err := svc.UploadServerCertificate(input)
  2350  	if err != nil {
  2351  		if aerr, ok := err.(awserr.Error); ok {
  2352  			switch aerr.Code() {
  2353  			case iam.ErrCodeLimitExceededException:
  2354  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2355  			case iam.ErrCodeInvalidInputException:
  2356  				fmt.Println(iam.ErrCodeInvalidInputException, aerr.Error())
  2357  			case iam.ErrCodeEntityAlreadyExistsException:
  2358  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
  2359  			case iam.ErrCodeMalformedCertificateException:
  2360  				fmt.Println(iam.ErrCodeMalformedCertificateException, aerr.Error())
  2361  			case iam.ErrCodeKeyPairMismatchException:
  2362  				fmt.Println(iam.ErrCodeKeyPairMismatchException, aerr.Error())
  2363  			case iam.ErrCodeConcurrentModificationException:
  2364  				fmt.Println(iam.ErrCodeConcurrentModificationException, aerr.Error())
  2365  			case iam.ErrCodeServiceFailureException:
  2366  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2367  			default:
  2368  				fmt.Println(aerr.Error())
  2369  			}
  2370  		} else {
  2371  			// Print the error, cast err to awserr.Error to get the Code and
  2372  			// Message from an error.
  2373  			fmt.Println(err.Error())
  2374  		}
  2375  		return
  2376  	}
  2377  
  2378  	fmt.Println(result)
  2379  }
  2380  
  2381  // To upload a signing certificate for an IAM user
  2382  //
  2383  // The following command uploads a signing certificate for the IAM user named Bob.
  2384  func ExampleIAM_UploadSigningCertificate_shared00() {
  2385  	svc := iam.New(session.New())
  2386  	input := &iam.UploadSigningCertificateInput{
  2387  		CertificateBody: aws.String("-----BEGIN CERTIFICATE-----<certificate-body>-----END CERTIFICATE-----"),
  2388  		UserName:        aws.String("Bob"),
  2389  	}
  2390  
  2391  	result, err := svc.UploadSigningCertificate(input)
  2392  	if err != nil {
  2393  		if aerr, ok := err.(awserr.Error); ok {
  2394  			switch aerr.Code() {
  2395  			case iam.ErrCodeLimitExceededException:
  2396  				fmt.Println(iam.ErrCodeLimitExceededException, aerr.Error())
  2397  			case iam.ErrCodeEntityAlreadyExistsException:
  2398  				fmt.Println(iam.ErrCodeEntityAlreadyExistsException, aerr.Error())
  2399  			case iam.ErrCodeMalformedCertificateException:
  2400  				fmt.Println(iam.ErrCodeMalformedCertificateException, aerr.Error())
  2401  			case iam.ErrCodeInvalidCertificateException:
  2402  				fmt.Println(iam.ErrCodeInvalidCertificateException, aerr.Error())
  2403  			case iam.ErrCodeDuplicateCertificateException:
  2404  				fmt.Println(iam.ErrCodeDuplicateCertificateException, aerr.Error())
  2405  			case iam.ErrCodeNoSuchEntityException:
  2406  				fmt.Println(iam.ErrCodeNoSuchEntityException, aerr.Error())
  2407  			case iam.ErrCodeServiceFailureException:
  2408  				fmt.Println(iam.ErrCodeServiceFailureException, aerr.Error())
  2409  			default:
  2410  				fmt.Println(aerr.Error())
  2411  			}
  2412  		} else {
  2413  			// Print the error, cast err to awserr.Error to get the Code and
  2414  			// Message from an error.
  2415  			fmt.Println(err.Error())
  2416  		}
  2417  		return
  2418  	}
  2419  
  2420  	fmt.Println(result)
  2421  }