examples_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package ssm_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/ssm"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleSSM_AddTagsToResource() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := ssm.New(sess)
  20. params := &ssm.AddTagsToResourceInput{
  21. ResourceId: aws.String("ResourceId"), // Required
  22. ResourceType: aws.String("ResourceTypeForTagging"), // Required
  23. Tags: []*ssm.Tag{ // Required
  24. { // Required
  25. Key: aws.String("TagKey"), // Required
  26. Value: aws.String("TagValue"), // Required
  27. },
  28. // More values...
  29. },
  30. }
  31. resp, err := svc.AddTagsToResource(params)
  32. if err != nil {
  33. // Print the error, cast err to awserr.Error to get the Code and
  34. // Message from an error.
  35. fmt.Println(err.Error())
  36. return
  37. }
  38. // Pretty-print the response data.
  39. fmt.Println(resp)
  40. }
  41. func ExampleSSM_CancelCommand() {
  42. sess, err := session.NewSession()
  43. if err != nil {
  44. fmt.Println("failed to create session,", err)
  45. return
  46. }
  47. svc := ssm.New(sess)
  48. params := &ssm.CancelCommandInput{
  49. CommandId: aws.String("CommandId"), // Required
  50. InstanceIds: []*string{
  51. aws.String("InstanceId"), // Required
  52. // More values...
  53. },
  54. }
  55. resp, err := svc.CancelCommand(params)
  56. if err != nil {
  57. // Print the error, cast err to awserr.Error to get the Code and
  58. // Message from an error.
  59. fmt.Println(err.Error())
  60. return
  61. }
  62. // Pretty-print the response data.
  63. fmt.Println(resp)
  64. }
  65. func ExampleSSM_CreateActivation() {
  66. sess, err := session.NewSession()
  67. if err != nil {
  68. fmt.Println("failed to create session,", err)
  69. return
  70. }
  71. svc := ssm.New(sess)
  72. params := &ssm.CreateActivationInput{
  73. IamRole: aws.String("IamRole"), // Required
  74. DefaultInstanceName: aws.String("DefaultInstanceName"),
  75. Description: aws.String("ActivationDescription"),
  76. ExpirationDate: aws.Time(time.Now()),
  77. RegistrationLimit: aws.Int64(1),
  78. }
  79. resp, err := svc.CreateActivation(params)
  80. if err != nil {
  81. // Print the error, cast err to awserr.Error to get the Code and
  82. // Message from an error.
  83. fmt.Println(err.Error())
  84. return
  85. }
  86. // Pretty-print the response data.
  87. fmt.Println(resp)
  88. }
  89. func ExampleSSM_CreateAssociation() {
  90. sess, err := session.NewSession()
  91. if err != nil {
  92. fmt.Println("failed to create session,", err)
  93. return
  94. }
  95. svc := ssm.New(sess)
  96. params := &ssm.CreateAssociationInput{
  97. InstanceId: aws.String("InstanceId"), // Required
  98. Name: aws.String("DocumentName"), // Required
  99. Parameters: map[string][]*string{
  100. "Key": { // Required
  101. aws.String("ParameterValue"), // Required
  102. // More values...
  103. },
  104. // More values...
  105. },
  106. }
  107. resp, err := svc.CreateAssociation(params)
  108. if err != nil {
  109. // Print the error, cast err to awserr.Error to get the Code and
  110. // Message from an error.
  111. fmt.Println(err.Error())
  112. return
  113. }
  114. // Pretty-print the response data.
  115. fmt.Println(resp)
  116. }
  117. func ExampleSSM_CreateAssociationBatch() {
  118. sess, err := session.NewSession()
  119. if err != nil {
  120. fmt.Println("failed to create session,", err)
  121. return
  122. }
  123. svc := ssm.New(sess)
  124. params := &ssm.CreateAssociationBatchInput{
  125. Entries: []*ssm.CreateAssociationBatchRequestEntry{ // Required
  126. { // Required
  127. InstanceId: aws.String("InstanceId"),
  128. Name: aws.String("DocumentName"),
  129. Parameters: map[string][]*string{
  130. "Key": { // Required
  131. aws.String("ParameterValue"), // Required
  132. // More values...
  133. },
  134. // More values...
  135. },
  136. },
  137. // More values...
  138. },
  139. }
  140. resp, err := svc.CreateAssociationBatch(params)
  141. if err != nil {
  142. // Print the error, cast err to awserr.Error to get the Code and
  143. // Message from an error.
  144. fmt.Println(err.Error())
  145. return
  146. }
  147. // Pretty-print the response data.
  148. fmt.Println(resp)
  149. }
  150. func ExampleSSM_CreateDocument() {
  151. sess, err := session.NewSession()
  152. if err != nil {
  153. fmt.Println("failed to create session,", err)
  154. return
  155. }
  156. svc := ssm.New(sess)
  157. params := &ssm.CreateDocumentInput{
  158. Content: aws.String("DocumentContent"), // Required
  159. Name: aws.String("DocumentName"), // Required
  160. }
  161. resp, err := svc.CreateDocument(params)
  162. if err != nil {
  163. // Print the error, cast err to awserr.Error to get the Code and
  164. // Message from an error.
  165. fmt.Println(err.Error())
  166. return
  167. }
  168. // Pretty-print the response data.
  169. fmt.Println(resp)
  170. }
  171. func ExampleSSM_DeleteActivation() {
  172. sess, err := session.NewSession()
  173. if err != nil {
  174. fmt.Println("failed to create session,", err)
  175. return
  176. }
  177. svc := ssm.New(sess)
  178. params := &ssm.DeleteActivationInput{
  179. ActivationId: aws.String("ActivationId"), // Required
  180. }
  181. resp, err := svc.DeleteActivation(params)
  182. if err != nil {
  183. // Print the error, cast err to awserr.Error to get the Code and
  184. // Message from an error.
  185. fmt.Println(err.Error())
  186. return
  187. }
  188. // Pretty-print the response data.
  189. fmt.Println(resp)
  190. }
  191. func ExampleSSM_DeleteAssociation() {
  192. sess, err := session.NewSession()
  193. if err != nil {
  194. fmt.Println("failed to create session,", err)
  195. return
  196. }
  197. svc := ssm.New(sess)
  198. params := &ssm.DeleteAssociationInput{
  199. InstanceId: aws.String("InstanceId"), // Required
  200. Name: aws.String("DocumentName"), // Required
  201. }
  202. resp, err := svc.DeleteAssociation(params)
  203. if err != nil {
  204. // Print the error, cast err to awserr.Error to get the Code and
  205. // Message from an error.
  206. fmt.Println(err.Error())
  207. return
  208. }
  209. // Pretty-print the response data.
  210. fmt.Println(resp)
  211. }
  212. func ExampleSSM_DeleteDocument() {
  213. sess, err := session.NewSession()
  214. if err != nil {
  215. fmt.Println("failed to create session,", err)
  216. return
  217. }
  218. svc := ssm.New(sess)
  219. params := &ssm.DeleteDocumentInput{
  220. Name: aws.String("DocumentName"), // Required
  221. }
  222. resp, err := svc.DeleteDocument(params)
  223. if err != nil {
  224. // Print the error, cast err to awserr.Error to get the Code and
  225. // Message from an error.
  226. fmt.Println(err.Error())
  227. return
  228. }
  229. // Pretty-print the response data.
  230. fmt.Println(resp)
  231. }
  232. func ExampleSSM_DeregisterManagedInstance() {
  233. sess, err := session.NewSession()
  234. if err != nil {
  235. fmt.Println("failed to create session,", err)
  236. return
  237. }
  238. svc := ssm.New(sess)
  239. params := &ssm.DeregisterManagedInstanceInput{
  240. InstanceId: aws.String("ManagedInstanceId"), // Required
  241. }
  242. resp, err := svc.DeregisterManagedInstance(params)
  243. if err != nil {
  244. // Print the error, cast err to awserr.Error to get the Code and
  245. // Message from an error.
  246. fmt.Println(err.Error())
  247. return
  248. }
  249. // Pretty-print the response data.
  250. fmt.Println(resp)
  251. }
  252. func ExampleSSM_DescribeActivations() {
  253. sess, err := session.NewSession()
  254. if err != nil {
  255. fmt.Println("failed to create session,", err)
  256. return
  257. }
  258. svc := ssm.New(sess)
  259. params := &ssm.DescribeActivationsInput{
  260. Filters: []*ssm.DescribeActivationsFilter{
  261. { // Required
  262. FilterKey: aws.String("DescribeActivationsFilterKeys"),
  263. FilterValues: []*string{
  264. aws.String("String"), // Required
  265. // More values...
  266. },
  267. },
  268. // More values...
  269. },
  270. MaxResults: aws.Int64(1),
  271. NextToken: aws.String("NextToken"),
  272. }
  273. resp, err := svc.DescribeActivations(params)
  274. if err != nil {
  275. // Print the error, cast err to awserr.Error to get the Code and
  276. // Message from an error.
  277. fmt.Println(err.Error())
  278. return
  279. }
  280. // Pretty-print the response data.
  281. fmt.Println(resp)
  282. }
  283. func ExampleSSM_DescribeAssociation() {
  284. sess, err := session.NewSession()
  285. if err != nil {
  286. fmt.Println("failed to create session,", err)
  287. return
  288. }
  289. svc := ssm.New(sess)
  290. params := &ssm.DescribeAssociationInput{
  291. InstanceId: aws.String("InstanceId"), // Required
  292. Name: aws.String("DocumentName"), // Required
  293. }
  294. resp, err := svc.DescribeAssociation(params)
  295. if err != nil {
  296. // Print the error, cast err to awserr.Error to get the Code and
  297. // Message from an error.
  298. fmt.Println(err.Error())
  299. return
  300. }
  301. // Pretty-print the response data.
  302. fmt.Println(resp)
  303. }
  304. func ExampleSSM_DescribeDocument() {
  305. sess, err := session.NewSession()
  306. if err != nil {
  307. fmt.Println("failed to create session,", err)
  308. return
  309. }
  310. svc := ssm.New(sess)
  311. params := &ssm.DescribeDocumentInput{
  312. Name: aws.String("DocumentARN"), // Required
  313. }
  314. resp, err := svc.DescribeDocument(params)
  315. if err != nil {
  316. // Print the error, cast err to awserr.Error to get the Code and
  317. // Message from an error.
  318. fmt.Println(err.Error())
  319. return
  320. }
  321. // Pretty-print the response data.
  322. fmt.Println(resp)
  323. }
  324. func ExampleSSM_DescribeDocumentPermission() {
  325. sess, err := session.NewSession()
  326. if err != nil {
  327. fmt.Println("failed to create session,", err)
  328. return
  329. }
  330. svc := ssm.New(sess)
  331. params := &ssm.DescribeDocumentPermissionInput{
  332. Name: aws.String("DocumentName"), // Required
  333. PermissionType: aws.String("DocumentPermissionType"), // Required
  334. }
  335. resp, err := svc.DescribeDocumentPermission(params)
  336. if err != nil {
  337. // Print the error, cast err to awserr.Error to get the Code and
  338. // Message from an error.
  339. fmt.Println(err.Error())
  340. return
  341. }
  342. // Pretty-print the response data.
  343. fmt.Println(resp)
  344. }
  345. func ExampleSSM_DescribeInstanceInformation() {
  346. sess, err := session.NewSession()
  347. if err != nil {
  348. fmt.Println("failed to create session,", err)
  349. return
  350. }
  351. svc := ssm.New(sess)
  352. params := &ssm.DescribeInstanceInformationInput{
  353. InstanceInformationFilterList: []*ssm.InstanceInformationFilter{
  354. { // Required
  355. Key: aws.String("InstanceInformationFilterKey"), // Required
  356. ValueSet: []*string{ // Required
  357. aws.String("InstanceInformationFilterValue"), // Required
  358. // More values...
  359. },
  360. },
  361. // More values...
  362. },
  363. MaxResults: aws.Int64(1),
  364. NextToken: aws.String("NextToken"),
  365. }
  366. resp, err := svc.DescribeInstanceInformation(params)
  367. if err != nil {
  368. // Print the error, cast err to awserr.Error to get the Code and
  369. // Message from an error.
  370. fmt.Println(err.Error())
  371. return
  372. }
  373. // Pretty-print the response data.
  374. fmt.Println(resp)
  375. }
  376. func ExampleSSM_GetDocument() {
  377. sess, err := session.NewSession()
  378. if err != nil {
  379. fmt.Println("failed to create session,", err)
  380. return
  381. }
  382. svc := ssm.New(sess)
  383. params := &ssm.GetDocumentInput{
  384. Name: aws.String("DocumentARN"), // Required
  385. }
  386. resp, err := svc.GetDocument(params)
  387. if err != nil {
  388. // Print the error, cast err to awserr.Error to get the Code and
  389. // Message from an error.
  390. fmt.Println(err.Error())
  391. return
  392. }
  393. // Pretty-print the response data.
  394. fmt.Println(resp)
  395. }
  396. func ExampleSSM_ListAssociations() {
  397. sess, err := session.NewSession()
  398. if err != nil {
  399. fmt.Println("failed to create session,", err)
  400. return
  401. }
  402. svc := ssm.New(sess)
  403. params := &ssm.ListAssociationsInput{
  404. AssociationFilterList: []*ssm.AssociationFilter{ // Required
  405. { // Required
  406. Key: aws.String("AssociationFilterKey"), // Required
  407. Value: aws.String("AssociationFilterValue"), // Required
  408. },
  409. // More values...
  410. },
  411. MaxResults: aws.Int64(1),
  412. NextToken: aws.String("NextToken"),
  413. }
  414. resp, err := svc.ListAssociations(params)
  415. if err != nil {
  416. // Print the error, cast err to awserr.Error to get the Code and
  417. // Message from an error.
  418. fmt.Println(err.Error())
  419. return
  420. }
  421. // Pretty-print the response data.
  422. fmt.Println(resp)
  423. }
  424. func ExampleSSM_ListCommandInvocations() {
  425. sess, err := session.NewSession()
  426. if err != nil {
  427. fmt.Println("failed to create session,", err)
  428. return
  429. }
  430. svc := ssm.New(sess)
  431. params := &ssm.ListCommandInvocationsInput{
  432. CommandId: aws.String("CommandId"),
  433. Details: aws.Bool(true),
  434. Filters: []*ssm.CommandFilter{
  435. { // Required
  436. Key: aws.String("CommandFilterKey"), // Required
  437. Value: aws.String("CommandFilterValue"), // Required
  438. },
  439. // More values...
  440. },
  441. InstanceId: aws.String("InstanceId"),
  442. MaxResults: aws.Int64(1),
  443. NextToken: aws.String("NextToken"),
  444. }
  445. resp, err := svc.ListCommandInvocations(params)
  446. if err != nil {
  447. // Print the error, cast err to awserr.Error to get the Code and
  448. // Message from an error.
  449. fmt.Println(err.Error())
  450. return
  451. }
  452. // Pretty-print the response data.
  453. fmt.Println(resp)
  454. }
  455. func ExampleSSM_ListCommands() {
  456. sess, err := session.NewSession()
  457. if err != nil {
  458. fmt.Println("failed to create session,", err)
  459. return
  460. }
  461. svc := ssm.New(sess)
  462. params := &ssm.ListCommandsInput{
  463. CommandId: aws.String("CommandId"),
  464. Filters: []*ssm.CommandFilter{
  465. { // Required
  466. Key: aws.String("CommandFilterKey"), // Required
  467. Value: aws.String("CommandFilterValue"), // Required
  468. },
  469. // More values...
  470. },
  471. InstanceId: aws.String("InstanceId"),
  472. MaxResults: aws.Int64(1),
  473. NextToken: aws.String("NextToken"),
  474. }
  475. resp, err := svc.ListCommands(params)
  476. if err != nil {
  477. // Print the error, cast err to awserr.Error to get the Code and
  478. // Message from an error.
  479. fmt.Println(err.Error())
  480. return
  481. }
  482. // Pretty-print the response data.
  483. fmt.Println(resp)
  484. }
  485. func ExampleSSM_ListDocuments() {
  486. sess, err := session.NewSession()
  487. if err != nil {
  488. fmt.Println("failed to create session,", err)
  489. return
  490. }
  491. svc := ssm.New(sess)
  492. params := &ssm.ListDocumentsInput{
  493. DocumentFilterList: []*ssm.DocumentFilter{
  494. { // Required
  495. Key: aws.String("DocumentFilterKey"), // Required
  496. Value: aws.String("DocumentFilterValue"), // Required
  497. },
  498. // More values...
  499. },
  500. MaxResults: aws.Int64(1),
  501. NextToken: aws.String("NextToken"),
  502. }
  503. resp, err := svc.ListDocuments(params)
  504. if err != nil {
  505. // Print the error, cast err to awserr.Error to get the Code and
  506. // Message from an error.
  507. fmt.Println(err.Error())
  508. return
  509. }
  510. // Pretty-print the response data.
  511. fmt.Println(resp)
  512. }
  513. func ExampleSSM_ListTagsForResource() {
  514. sess, err := session.NewSession()
  515. if err != nil {
  516. fmt.Println("failed to create session,", err)
  517. return
  518. }
  519. svc := ssm.New(sess)
  520. params := &ssm.ListTagsForResourceInput{
  521. ResourceId: aws.String("ResourceId"), // Required
  522. ResourceType: aws.String("ResourceTypeForTagging"), // Required
  523. }
  524. resp, err := svc.ListTagsForResource(params)
  525. if err != nil {
  526. // Print the error, cast err to awserr.Error to get the Code and
  527. // Message from an error.
  528. fmt.Println(err.Error())
  529. return
  530. }
  531. // Pretty-print the response data.
  532. fmt.Println(resp)
  533. }
  534. func ExampleSSM_ModifyDocumentPermission() {
  535. sess, err := session.NewSession()
  536. if err != nil {
  537. fmt.Println("failed to create session,", err)
  538. return
  539. }
  540. svc := ssm.New(sess)
  541. params := &ssm.ModifyDocumentPermissionInput{
  542. Name: aws.String("DocumentName"), // Required
  543. PermissionType: aws.String("DocumentPermissionType"), // Required
  544. AccountIdsToAdd: []*string{
  545. aws.String("AccountId"), // Required
  546. // More values...
  547. },
  548. AccountIdsToRemove: []*string{
  549. aws.String("AccountId"), // Required
  550. // More values...
  551. },
  552. }
  553. resp, err := svc.ModifyDocumentPermission(params)
  554. if err != nil {
  555. // Print the error, cast err to awserr.Error to get the Code and
  556. // Message from an error.
  557. fmt.Println(err.Error())
  558. return
  559. }
  560. // Pretty-print the response data.
  561. fmt.Println(resp)
  562. }
  563. func ExampleSSM_RemoveTagsFromResource() {
  564. sess, err := session.NewSession()
  565. if err != nil {
  566. fmt.Println("failed to create session,", err)
  567. return
  568. }
  569. svc := ssm.New(sess)
  570. params := &ssm.RemoveTagsFromResourceInput{
  571. ResourceId: aws.String("ResourceId"), // Required
  572. ResourceType: aws.String("ResourceTypeForTagging"), // Required
  573. TagKeys: []*string{ // Required
  574. aws.String("TagKey"), // Required
  575. // More values...
  576. },
  577. }
  578. resp, err := svc.RemoveTagsFromResource(params)
  579. if err != nil {
  580. // Print the error, cast err to awserr.Error to get the Code and
  581. // Message from an error.
  582. fmt.Println(err.Error())
  583. return
  584. }
  585. // Pretty-print the response data.
  586. fmt.Println(resp)
  587. }
  588. func ExampleSSM_SendCommand() {
  589. sess, err := session.NewSession()
  590. if err != nil {
  591. fmt.Println("failed to create session,", err)
  592. return
  593. }
  594. svc := ssm.New(sess)
  595. params := &ssm.SendCommandInput{
  596. DocumentName: aws.String("DocumentARN"), // Required
  597. InstanceIds: []*string{ // Required
  598. aws.String("InstanceId"), // Required
  599. // More values...
  600. },
  601. Comment: aws.String("Comment"),
  602. DocumentHash: aws.String("DocumentHash"),
  603. DocumentHashType: aws.String("DocumentHashType"),
  604. NotificationConfig: &ssm.NotificationConfig{
  605. NotificationArn: aws.String("NotificationArn"),
  606. NotificationEvents: []*string{
  607. aws.String("NotificationEvent"), // Required
  608. // More values...
  609. },
  610. NotificationType: aws.String("NotificationType"),
  611. },
  612. OutputS3BucketName: aws.String("S3BucketName"),
  613. OutputS3KeyPrefix: aws.String("S3KeyPrefix"),
  614. Parameters: map[string][]*string{
  615. "Key": { // Required
  616. aws.String("ParameterValue"), // Required
  617. // More values...
  618. },
  619. // More values...
  620. },
  621. ServiceRoleArn: aws.String("ServiceRole"),
  622. TimeoutSeconds: aws.Int64(1),
  623. }
  624. resp, err := svc.SendCommand(params)
  625. if err != nil {
  626. // Print the error, cast err to awserr.Error to get the Code and
  627. // Message from an error.
  628. fmt.Println(err.Error())
  629. return
  630. }
  631. // Pretty-print the response data.
  632. fmt.Println(resp)
  633. }
  634. func ExampleSSM_UpdateAssociationStatus() {
  635. sess, err := session.NewSession()
  636. if err != nil {
  637. fmt.Println("failed to create session,", err)
  638. return
  639. }
  640. svc := ssm.New(sess)
  641. params := &ssm.UpdateAssociationStatusInput{
  642. AssociationStatus: &ssm.AssociationStatus{ // Required
  643. Date: aws.Time(time.Now()), // Required
  644. Message: aws.String("StatusMessage"), // Required
  645. Name: aws.String("AssociationStatusName"), // Required
  646. AdditionalInfo: aws.String("StatusAdditionalInfo"),
  647. },
  648. InstanceId: aws.String("InstanceId"), // Required
  649. Name: aws.String("DocumentName"), // Required
  650. }
  651. resp, err := svc.UpdateAssociationStatus(params)
  652. if err != nil {
  653. // Print the error, cast err to awserr.Error to get the Code and
  654. // Message from an error.
  655. fmt.Println(err.Error())
  656. return
  657. }
  658. // Pretty-print the response data.
  659. fmt.Println(resp)
  660. }
  661. func ExampleSSM_UpdateManagedInstanceRole() {
  662. sess, err := session.NewSession()
  663. if err != nil {
  664. fmt.Println("failed to create session,", err)
  665. return
  666. }
  667. svc := ssm.New(sess)
  668. params := &ssm.UpdateManagedInstanceRoleInput{
  669. IamRole: aws.String("IamRole"), // Required
  670. InstanceId: aws.String("ManagedInstanceId"), // Required
  671. }
  672. resp, err := svc.UpdateManagedInstanceRole(params)
  673. if err != nil {
  674. // Print the error, cast err to awserr.Error to get the Code and
  675. // Message from an error.
  676. fmt.Println(err.Error())
  677. return
  678. }
  679. // Pretty-print the response data.
  680. fmt.Println(resp)
  681. }