examples_test.go 18 KB

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