examples_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudformation_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/cloudformation"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleCloudFormation_CancelUpdateStack() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := cloudformation.New(sess)
  20. params := &cloudformation.CancelUpdateStackInput{
  21. StackName: aws.String("StackName"), // Required
  22. }
  23. resp, err := svc.CancelUpdateStack(params)
  24. if err != nil {
  25. // Print the error, cast err to awserr.Error to get the Code and
  26. // Message from an error.
  27. fmt.Println(err.Error())
  28. return
  29. }
  30. // Pretty-print the response data.
  31. fmt.Println(resp)
  32. }
  33. func ExampleCloudFormation_ContinueUpdateRollback() {
  34. sess, err := session.NewSession()
  35. if err != nil {
  36. fmt.Println("failed to create session,", err)
  37. return
  38. }
  39. svc := cloudformation.New(sess)
  40. params := &cloudformation.ContinueUpdateRollbackInput{
  41. StackName: aws.String("StackNameOrId"), // Required
  42. RoleARN: aws.String("RoleARN"),
  43. }
  44. resp, err := svc.ContinueUpdateRollback(params)
  45. if err != nil {
  46. // Print the error, cast err to awserr.Error to get the Code and
  47. // Message from an error.
  48. fmt.Println(err.Error())
  49. return
  50. }
  51. // Pretty-print the response data.
  52. fmt.Println(resp)
  53. }
  54. func ExampleCloudFormation_CreateChangeSet() {
  55. sess, err := session.NewSession()
  56. if err != nil {
  57. fmt.Println("failed to create session,", err)
  58. return
  59. }
  60. svc := cloudformation.New(sess)
  61. params := &cloudformation.CreateChangeSetInput{
  62. ChangeSetName: aws.String("ChangeSetName"), // Required
  63. StackName: aws.String("StackNameOrId"), // Required
  64. Capabilities: []*string{
  65. aws.String("Capability"), // Required
  66. // More values...
  67. },
  68. ClientToken: aws.String("ClientToken"),
  69. Description: aws.String("Description"),
  70. NotificationARNs: []*string{
  71. aws.String("NotificationARN"), // Required
  72. // More values...
  73. },
  74. Parameters: []*cloudformation.Parameter{
  75. { // Required
  76. ParameterKey: aws.String("ParameterKey"),
  77. ParameterValue: aws.String("ParameterValue"),
  78. UsePreviousValue: aws.Bool(true),
  79. },
  80. // More values...
  81. },
  82. ResourceTypes: []*string{
  83. aws.String("ResourceType"), // Required
  84. // More values...
  85. },
  86. RoleARN: aws.String("RoleARN"),
  87. Tags: []*cloudformation.Tag{
  88. { // Required
  89. Key: aws.String("TagKey"),
  90. Value: aws.String("TagValue"),
  91. },
  92. // More values...
  93. },
  94. TemplateBody: aws.String("TemplateBody"),
  95. TemplateURL: aws.String("TemplateURL"),
  96. UsePreviousTemplate: aws.Bool(true),
  97. }
  98. resp, err := svc.CreateChangeSet(params)
  99. if err != nil {
  100. // Print the error, cast err to awserr.Error to get the Code and
  101. // Message from an error.
  102. fmt.Println(err.Error())
  103. return
  104. }
  105. // Pretty-print the response data.
  106. fmt.Println(resp)
  107. }
  108. func ExampleCloudFormation_CreateStack() {
  109. sess, err := session.NewSession()
  110. if err != nil {
  111. fmt.Println("failed to create session,", err)
  112. return
  113. }
  114. svc := cloudformation.New(sess)
  115. params := &cloudformation.CreateStackInput{
  116. StackName: aws.String("StackName"), // Required
  117. Capabilities: []*string{
  118. aws.String("Capability"), // Required
  119. // More values...
  120. },
  121. DisableRollback: aws.Bool(true),
  122. NotificationARNs: []*string{
  123. aws.String("NotificationARN"), // Required
  124. // More values...
  125. },
  126. OnFailure: aws.String("OnFailure"),
  127. Parameters: []*cloudformation.Parameter{
  128. { // Required
  129. ParameterKey: aws.String("ParameterKey"),
  130. ParameterValue: aws.String("ParameterValue"),
  131. UsePreviousValue: aws.Bool(true),
  132. },
  133. // More values...
  134. },
  135. ResourceTypes: []*string{
  136. aws.String("ResourceType"), // Required
  137. // More values...
  138. },
  139. RoleARN: aws.String("RoleARN"),
  140. StackPolicyBody: aws.String("StackPolicyBody"),
  141. StackPolicyURL: aws.String("StackPolicyURL"),
  142. Tags: []*cloudformation.Tag{
  143. { // Required
  144. Key: aws.String("TagKey"),
  145. Value: aws.String("TagValue"),
  146. },
  147. // More values...
  148. },
  149. TemplateBody: aws.String("TemplateBody"),
  150. TemplateURL: aws.String("TemplateURL"),
  151. TimeoutInMinutes: aws.Int64(1),
  152. }
  153. resp, err := svc.CreateStack(params)
  154. if err != nil {
  155. // Print the error, cast err to awserr.Error to get the Code and
  156. // Message from an error.
  157. fmt.Println(err.Error())
  158. return
  159. }
  160. // Pretty-print the response data.
  161. fmt.Println(resp)
  162. }
  163. func ExampleCloudFormation_DeleteChangeSet() {
  164. sess, err := session.NewSession()
  165. if err != nil {
  166. fmt.Println("failed to create session,", err)
  167. return
  168. }
  169. svc := cloudformation.New(sess)
  170. params := &cloudformation.DeleteChangeSetInput{
  171. ChangeSetName: aws.String("ChangeSetNameOrId"), // Required
  172. StackName: aws.String("StackNameOrId"),
  173. }
  174. resp, err := svc.DeleteChangeSet(params)
  175. if err != nil {
  176. // Print the error, cast err to awserr.Error to get the Code and
  177. // Message from an error.
  178. fmt.Println(err.Error())
  179. return
  180. }
  181. // Pretty-print the response data.
  182. fmt.Println(resp)
  183. }
  184. func ExampleCloudFormation_DeleteStack() {
  185. sess, err := session.NewSession()
  186. if err != nil {
  187. fmt.Println("failed to create session,", err)
  188. return
  189. }
  190. svc := cloudformation.New(sess)
  191. params := &cloudformation.DeleteStackInput{
  192. StackName: aws.String("StackName"), // Required
  193. RetainResources: []*string{
  194. aws.String("LogicalResourceId"), // Required
  195. // More values...
  196. },
  197. RoleARN: aws.String("RoleARN"),
  198. }
  199. resp, err := svc.DeleteStack(params)
  200. if err != nil {
  201. // Print the error, cast err to awserr.Error to get the Code and
  202. // Message from an error.
  203. fmt.Println(err.Error())
  204. return
  205. }
  206. // Pretty-print the response data.
  207. fmt.Println(resp)
  208. }
  209. func ExampleCloudFormation_DescribeAccountLimits() {
  210. sess, err := session.NewSession()
  211. if err != nil {
  212. fmt.Println("failed to create session,", err)
  213. return
  214. }
  215. svc := cloudformation.New(sess)
  216. params := &cloudformation.DescribeAccountLimitsInput{
  217. NextToken: aws.String("NextToken"),
  218. }
  219. resp, err := svc.DescribeAccountLimits(params)
  220. if err != nil {
  221. // Print the error, cast err to awserr.Error to get the Code and
  222. // Message from an error.
  223. fmt.Println(err.Error())
  224. return
  225. }
  226. // Pretty-print the response data.
  227. fmt.Println(resp)
  228. }
  229. func ExampleCloudFormation_DescribeChangeSet() {
  230. sess, err := session.NewSession()
  231. if err != nil {
  232. fmt.Println("failed to create session,", err)
  233. return
  234. }
  235. svc := cloudformation.New(sess)
  236. params := &cloudformation.DescribeChangeSetInput{
  237. ChangeSetName: aws.String("ChangeSetNameOrId"), // Required
  238. NextToken: aws.String("NextToken"),
  239. StackName: aws.String("StackNameOrId"),
  240. }
  241. resp, err := svc.DescribeChangeSet(params)
  242. if err != nil {
  243. // Print the error, cast err to awserr.Error to get the Code and
  244. // Message from an error.
  245. fmt.Println(err.Error())
  246. return
  247. }
  248. // Pretty-print the response data.
  249. fmt.Println(resp)
  250. }
  251. func ExampleCloudFormation_DescribeStackEvents() {
  252. sess, err := session.NewSession()
  253. if err != nil {
  254. fmt.Println("failed to create session,", err)
  255. return
  256. }
  257. svc := cloudformation.New(sess)
  258. params := &cloudformation.DescribeStackEventsInput{
  259. NextToken: aws.String("NextToken"),
  260. StackName: aws.String("StackName"),
  261. }
  262. resp, err := svc.DescribeStackEvents(params)
  263. if err != nil {
  264. // Print the error, cast err to awserr.Error to get the Code and
  265. // Message from an error.
  266. fmt.Println(err.Error())
  267. return
  268. }
  269. // Pretty-print the response data.
  270. fmt.Println(resp)
  271. }
  272. func ExampleCloudFormation_DescribeStackResource() {
  273. sess, err := session.NewSession()
  274. if err != nil {
  275. fmt.Println("failed to create session,", err)
  276. return
  277. }
  278. svc := cloudformation.New(sess)
  279. params := &cloudformation.DescribeStackResourceInput{
  280. LogicalResourceId: aws.String("LogicalResourceId"), // Required
  281. StackName: aws.String("StackName"), // Required
  282. }
  283. resp, err := svc.DescribeStackResource(params)
  284. if err != nil {
  285. // Print the error, cast err to awserr.Error to get the Code and
  286. // Message from an error.
  287. fmt.Println(err.Error())
  288. return
  289. }
  290. // Pretty-print the response data.
  291. fmt.Println(resp)
  292. }
  293. func ExampleCloudFormation_DescribeStackResources() {
  294. sess, err := session.NewSession()
  295. if err != nil {
  296. fmt.Println("failed to create session,", err)
  297. return
  298. }
  299. svc := cloudformation.New(sess)
  300. params := &cloudformation.DescribeStackResourcesInput{
  301. LogicalResourceId: aws.String("LogicalResourceId"),
  302. PhysicalResourceId: aws.String("PhysicalResourceId"),
  303. StackName: aws.String("StackName"),
  304. }
  305. resp, err := svc.DescribeStackResources(params)
  306. if err != nil {
  307. // Print the error, cast err to awserr.Error to get the Code and
  308. // Message from an error.
  309. fmt.Println(err.Error())
  310. return
  311. }
  312. // Pretty-print the response data.
  313. fmt.Println(resp)
  314. }
  315. func ExampleCloudFormation_DescribeStacks() {
  316. sess, err := session.NewSession()
  317. if err != nil {
  318. fmt.Println("failed to create session,", err)
  319. return
  320. }
  321. svc := cloudformation.New(sess)
  322. params := &cloudformation.DescribeStacksInput{
  323. NextToken: aws.String("NextToken"),
  324. StackName: aws.String("StackName"),
  325. }
  326. resp, err := svc.DescribeStacks(params)
  327. if err != nil {
  328. // Print the error, cast err to awserr.Error to get the Code and
  329. // Message from an error.
  330. fmt.Println(err.Error())
  331. return
  332. }
  333. // Pretty-print the response data.
  334. fmt.Println(resp)
  335. }
  336. func ExampleCloudFormation_EstimateTemplateCost() {
  337. sess, err := session.NewSession()
  338. if err != nil {
  339. fmt.Println("failed to create session,", err)
  340. return
  341. }
  342. svc := cloudformation.New(sess)
  343. params := &cloudformation.EstimateTemplateCostInput{
  344. Parameters: []*cloudformation.Parameter{
  345. { // Required
  346. ParameterKey: aws.String("ParameterKey"),
  347. ParameterValue: aws.String("ParameterValue"),
  348. UsePreviousValue: aws.Bool(true),
  349. },
  350. // More values...
  351. },
  352. TemplateBody: aws.String("TemplateBody"),
  353. TemplateURL: aws.String("TemplateURL"),
  354. }
  355. resp, err := svc.EstimateTemplateCost(params)
  356. if err != nil {
  357. // Print the error, cast err to awserr.Error to get the Code and
  358. // Message from an error.
  359. fmt.Println(err.Error())
  360. return
  361. }
  362. // Pretty-print the response data.
  363. fmt.Println(resp)
  364. }
  365. func ExampleCloudFormation_ExecuteChangeSet() {
  366. sess, err := session.NewSession()
  367. if err != nil {
  368. fmt.Println("failed to create session,", err)
  369. return
  370. }
  371. svc := cloudformation.New(sess)
  372. params := &cloudformation.ExecuteChangeSetInput{
  373. ChangeSetName: aws.String("ChangeSetNameOrId"), // Required
  374. StackName: aws.String("StackNameOrId"),
  375. }
  376. resp, err := svc.ExecuteChangeSet(params)
  377. if err != nil {
  378. // Print the error, cast err to awserr.Error to get the Code and
  379. // Message from an error.
  380. fmt.Println(err.Error())
  381. return
  382. }
  383. // Pretty-print the response data.
  384. fmt.Println(resp)
  385. }
  386. func ExampleCloudFormation_GetStackPolicy() {
  387. sess, err := session.NewSession()
  388. if err != nil {
  389. fmt.Println("failed to create session,", err)
  390. return
  391. }
  392. svc := cloudformation.New(sess)
  393. params := &cloudformation.GetStackPolicyInput{
  394. StackName: aws.String("StackName"), // Required
  395. }
  396. resp, err := svc.GetStackPolicy(params)
  397. if err != nil {
  398. // Print the error, cast err to awserr.Error to get the Code and
  399. // Message from an error.
  400. fmt.Println(err.Error())
  401. return
  402. }
  403. // Pretty-print the response data.
  404. fmt.Println(resp)
  405. }
  406. func ExampleCloudFormation_GetTemplate() {
  407. sess, err := session.NewSession()
  408. if err != nil {
  409. fmt.Println("failed to create session,", err)
  410. return
  411. }
  412. svc := cloudformation.New(sess)
  413. params := &cloudformation.GetTemplateInput{
  414. StackName: aws.String("StackName"), // Required
  415. }
  416. resp, err := svc.GetTemplate(params)
  417. if err != nil {
  418. // Print the error, cast err to awserr.Error to get the Code and
  419. // Message from an error.
  420. fmt.Println(err.Error())
  421. return
  422. }
  423. // Pretty-print the response data.
  424. fmt.Println(resp)
  425. }
  426. func ExampleCloudFormation_GetTemplateSummary() {
  427. sess, err := session.NewSession()
  428. if err != nil {
  429. fmt.Println("failed to create session,", err)
  430. return
  431. }
  432. svc := cloudformation.New(sess)
  433. params := &cloudformation.GetTemplateSummaryInput{
  434. StackName: aws.String("StackNameOrId"),
  435. TemplateBody: aws.String("TemplateBody"),
  436. TemplateURL: aws.String("TemplateURL"),
  437. }
  438. resp, err := svc.GetTemplateSummary(params)
  439. if err != nil {
  440. // Print the error, cast err to awserr.Error to get the Code and
  441. // Message from an error.
  442. fmt.Println(err.Error())
  443. return
  444. }
  445. // Pretty-print the response data.
  446. fmt.Println(resp)
  447. }
  448. func ExampleCloudFormation_ListChangeSets() {
  449. sess, err := session.NewSession()
  450. if err != nil {
  451. fmt.Println("failed to create session,", err)
  452. return
  453. }
  454. svc := cloudformation.New(sess)
  455. params := &cloudformation.ListChangeSetsInput{
  456. StackName: aws.String("StackNameOrId"), // Required
  457. NextToken: aws.String("NextToken"),
  458. }
  459. resp, err := svc.ListChangeSets(params)
  460. if err != nil {
  461. // Print the error, cast err to awserr.Error to get the Code and
  462. // Message from an error.
  463. fmt.Println(err.Error())
  464. return
  465. }
  466. // Pretty-print the response data.
  467. fmt.Println(resp)
  468. }
  469. func ExampleCloudFormation_ListStackResources() {
  470. sess, err := session.NewSession()
  471. if err != nil {
  472. fmt.Println("failed to create session,", err)
  473. return
  474. }
  475. svc := cloudformation.New(sess)
  476. params := &cloudformation.ListStackResourcesInput{
  477. StackName: aws.String("StackName"), // Required
  478. NextToken: aws.String("NextToken"),
  479. }
  480. resp, err := svc.ListStackResources(params)
  481. if err != nil {
  482. // Print the error, cast err to awserr.Error to get the Code and
  483. // Message from an error.
  484. fmt.Println(err.Error())
  485. return
  486. }
  487. // Pretty-print the response data.
  488. fmt.Println(resp)
  489. }
  490. func ExampleCloudFormation_ListStacks() {
  491. sess, err := session.NewSession()
  492. if err != nil {
  493. fmt.Println("failed to create session,", err)
  494. return
  495. }
  496. svc := cloudformation.New(sess)
  497. params := &cloudformation.ListStacksInput{
  498. NextToken: aws.String("NextToken"),
  499. StackStatusFilter: []*string{
  500. aws.String("StackStatus"), // Required
  501. // More values...
  502. },
  503. }
  504. resp, err := svc.ListStacks(params)
  505. if err != nil {
  506. // Print the error, cast err to awserr.Error to get the Code and
  507. // Message from an error.
  508. fmt.Println(err.Error())
  509. return
  510. }
  511. // Pretty-print the response data.
  512. fmt.Println(resp)
  513. }
  514. func ExampleCloudFormation_SetStackPolicy() {
  515. sess, err := session.NewSession()
  516. if err != nil {
  517. fmt.Println("failed to create session,", err)
  518. return
  519. }
  520. svc := cloudformation.New(sess)
  521. params := &cloudformation.SetStackPolicyInput{
  522. StackName: aws.String("StackName"), // Required
  523. StackPolicyBody: aws.String("StackPolicyBody"),
  524. StackPolicyURL: aws.String("StackPolicyURL"),
  525. }
  526. resp, err := svc.SetStackPolicy(params)
  527. if err != nil {
  528. // Print the error, cast err to awserr.Error to get the Code and
  529. // Message from an error.
  530. fmt.Println(err.Error())
  531. return
  532. }
  533. // Pretty-print the response data.
  534. fmt.Println(resp)
  535. }
  536. func ExampleCloudFormation_SignalResource() {
  537. sess, err := session.NewSession()
  538. if err != nil {
  539. fmt.Println("failed to create session,", err)
  540. return
  541. }
  542. svc := cloudformation.New(sess)
  543. params := &cloudformation.SignalResourceInput{
  544. LogicalResourceId: aws.String("LogicalResourceId"), // Required
  545. StackName: aws.String("StackNameOrId"), // Required
  546. Status: aws.String("ResourceSignalStatus"), // Required
  547. UniqueId: aws.String("ResourceSignalUniqueId"), // Required
  548. }
  549. resp, err := svc.SignalResource(params)
  550. if err != nil {
  551. // Print the error, cast err to awserr.Error to get the Code and
  552. // Message from an error.
  553. fmt.Println(err.Error())
  554. return
  555. }
  556. // Pretty-print the response data.
  557. fmt.Println(resp)
  558. }
  559. func ExampleCloudFormation_UpdateStack() {
  560. sess, err := session.NewSession()
  561. if err != nil {
  562. fmt.Println("failed to create session,", err)
  563. return
  564. }
  565. svc := cloudformation.New(sess)
  566. params := &cloudformation.UpdateStackInput{
  567. StackName: aws.String("StackName"), // Required
  568. Capabilities: []*string{
  569. aws.String("Capability"), // Required
  570. // More values...
  571. },
  572. NotificationARNs: []*string{
  573. aws.String("NotificationARN"), // Required
  574. // More values...
  575. },
  576. Parameters: []*cloudformation.Parameter{
  577. { // Required
  578. ParameterKey: aws.String("ParameterKey"),
  579. ParameterValue: aws.String("ParameterValue"),
  580. UsePreviousValue: aws.Bool(true),
  581. },
  582. // More values...
  583. },
  584. ResourceTypes: []*string{
  585. aws.String("ResourceType"), // Required
  586. // More values...
  587. },
  588. RoleARN: aws.String("RoleARN"),
  589. StackPolicyBody: aws.String("StackPolicyBody"),
  590. StackPolicyDuringUpdateBody: aws.String("StackPolicyDuringUpdateBody"),
  591. StackPolicyDuringUpdateURL: aws.String("StackPolicyDuringUpdateURL"),
  592. StackPolicyURL: aws.String("StackPolicyURL"),
  593. Tags: []*cloudformation.Tag{
  594. { // Required
  595. Key: aws.String("TagKey"),
  596. Value: aws.String("TagValue"),
  597. },
  598. // More values...
  599. },
  600. TemplateBody: aws.String("TemplateBody"),
  601. TemplateURL: aws.String("TemplateURL"),
  602. UsePreviousTemplate: aws.Bool(true),
  603. }
  604. resp, err := svc.UpdateStack(params)
  605. if err != nil {
  606. // Print the error, cast err to awserr.Error to get the Code and
  607. // Message from an error.
  608. fmt.Println(err.Error())
  609. return
  610. }
  611. // Pretty-print the response data.
  612. fmt.Println(resp)
  613. }
  614. func ExampleCloudFormation_ValidateTemplate() {
  615. sess, err := session.NewSession()
  616. if err != nil {
  617. fmt.Println("failed to create session,", err)
  618. return
  619. }
  620. svc := cloudformation.New(sess)
  621. params := &cloudformation.ValidateTemplateInput{
  622. TemplateBody: aws.String("TemplateBody"),
  623. TemplateURL: aws.String("TemplateURL"),
  624. }
  625. resp, err := svc.ValidateTemplate(params)
  626. if err != nil {
  627. // Print the error, cast err to awserr.Error to get the Code and
  628. // Message from an error.
  629. fmt.Println(err.Error())
  630. return
  631. }
  632. // Pretty-print the response data.
  633. fmt.Println(resp)
  634. }