1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudformation
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Updates a stack as specified in the template. After the call completes
15// successfully, the stack update starts. You can check the status of the stack via
16// the DescribeStacks action. To get a copy of the template for an existing stack,
17// you can use the GetTemplate action. For more information about creating an
18// update template, updating a stack, and monitoring the progress of the update,
19// see Updating a Stack
20// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html).
21func (c *Client) UpdateStack(ctx context.Context, params *UpdateStackInput, optFns ...func(*Options)) (*UpdateStackOutput, error) {
22	if params == nil {
23		params = &UpdateStackInput{}
24	}
25
26	result, metadata, err := c.invokeOperation(ctx, "UpdateStack", params, optFns, addOperationUpdateStackMiddlewares)
27	if err != nil {
28		return nil, err
29	}
30
31	out := result.(*UpdateStackOutput)
32	out.ResultMetadata = metadata
33	return out, nil
34}
35
36// The input for an UpdateStack action.
37type UpdateStackInput struct {
38
39	// The name or unique stack ID of the stack to update.
40	//
41	// This member is required.
42	StackName *string
43
44	// In some cases, you must explicitly acknowledge that your stack template contains
45	// certain capabilities in order for AWS CloudFormation to update the stack.
46	//
47	// *
48	// CAPABILITY_IAM and CAPABILITY_NAMED_IAM Some stack templates might include
49	// resources that can affect permissions in your AWS account; for example, by
50	// creating new AWS Identity and Access Management (IAM) users. For those stacks,
51	// you must explicitly acknowledge this by specifying one of these capabilities.
52	// The following IAM resources require you to specify either the CAPABILITY_IAM or
53	// CAPABILITY_NAMED_IAM capability.
54	//
55	// * If you have IAM resources, you can specify
56	// either capability.
57	//
58	// * If you have IAM resources with custom names, you must
59	// specify CAPABILITY_NAMED_IAM.
60	//
61	// * If you don't specify either of these
62	// capabilities, AWS CloudFormation returns an InsufficientCapabilities error.
63	//
64	// If
65	// your stack template contains these resources, we recommend that you review all
66	// permissions associated with them and edit their permissions if necessary.
67	//
68	// *
69	// AWS::IAM::AccessKey
70	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html)
71	//
72	// *
73	// AWS::IAM::Group
74	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-group.html)
75	//
76	// *
77	// AWS::IAM::InstanceProfile
78	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html)
79	//
80	// *
81	// AWS::IAM::Policy
82	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-policy.html)
83	//
84	// *
85	// AWS::IAM::Role
86	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html)
87	//
88	// *
89	// AWS::IAM::User
90	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html)
91	//
92	// *
93	// AWS::IAM::UserToGroupAddition
94	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-addusertogroup.html)
95	//
96	// For
97	// more information, see Acknowledging IAM Resources in AWS CloudFormation
98	// Templates
99	// (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#capabilities).
100	//
101	// *
102	// CAPABILITY_AUTO_EXPAND Some template contain macros. Macros perform custom
103	// processing on templates; this can include simple actions like find-and-replace
104	// operations, all the way to extensive transformations of entire templates.
105	// Because of this, users typically create a change set from the processed
106	// template, so that they can review the changes resulting from the macros before
107	// actually updating the stack. If your stack template contains one or more macros,
108	// and you choose to update a stack directly from the processed template, without
109	// first reviewing the resulting changes in a change set, you must acknowledge this
110	// capability. This includes the AWS::Include
111	// (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/create-reusable-transform-function-snippets-and-add-to-your-template-with-aws-include-transform.html)
112	// and AWS::Serverless
113	// (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-serverless.html)
114	// transforms, which are macros hosted by AWS CloudFormation. If you want to update
115	// a stack from a stack template that contains macros and nested stacks, you must
116	// update the stack directly from the template using this capability. You should
117	// only update stacks directly from a stack template that contains macros if you
118	// know what processing the macro performs. Each macro relies on an underlying
119	// Lambda service function for processing stack templates. Be aware that the Lambda
120	// function owner can update the function operation without AWS CloudFormation
121	// being notified. For more information, see Using AWS CloudFormation Macros to
122	// Perform Custom Processing on Templates
123	// (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html).
124	Capabilities []types.Capability
125
126	// A unique identifier for this UpdateStack request. Specify this token if you plan
127	// to retry requests so that AWS CloudFormation knows that you're not attempting to
128	// update a stack with the same name. You might retry UpdateStack requests to
129	// ensure that AWS CloudFormation successfully received them. All events triggered
130	// by a given stack operation are assigned the same client request token, which you
131	// can use to track operations. For example, if you execute a CreateStack operation
132	// with the token token1, then all the StackEvents generated by that operation will
133	// have ClientRequestToken set as token1. In the console, stack operations display
134	// the client request token on the Events tab. Stack operations that are initiated
135	// from the console use the token format Console-StackOperation-ID, which helps you
136	// easily identify the stack operation . For example, if you create a stack using
137	// the console, each stack event would be assigned the same token in the following
138	// format: Console-CreateStack-7f59c3cf-00d2-40c7-b2ff-e75db0987002.
139	ClientRequestToken *string
140
141	// Amazon Simple Notification Service topic Amazon Resource Names (ARNs) that AWS
142	// CloudFormation associates with the stack. Specify an empty list to remove all
143	// notification topics.
144	NotificationARNs []string
145
146	// A list of Parameter structures that specify input parameters for the stack. For
147	// more information, see the Parameter
148	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html)
149	// data type.
150	Parameters []types.Parameter
151
152	// The template resource types that you have permissions to work with for this
153	// update stack action, such as AWS::EC2::Instance, AWS::EC2::*, or
154	// Custom::MyCustomInstance. If the list of resource types doesn't include a
155	// resource that you're updating, the stack update fails. By default, AWS
156	// CloudFormation grants permissions to all resource types. AWS Identity and Access
157	// Management (IAM) uses this parameter for AWS CloudFormation-specific condition
158	// keys in IAM policies. For more information, see Controlling Access with AWS
159	// Identity and Access Management
160	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html).
161	ResourceTypes []string
162
163	// The Amazon Resource Name (ARN) of an AWS Identity and Access Management (IAM)
164	// role that AWS CloudFormation assumes to update the stack. AWS CloudFormation
165	// uses the role's credentials to make calls on your behalf. AWS CloudFormation
166	// always uses this role for all future operations on the stack. As long as users
167	// have permission to operate on the stack, AWS CloudFormation uses this role even
168	// if the users don't have permission to pass it. Ensure that the role grants least
169	// privilege. If you don't specify a value, AWS CloudFormation uses the role that
170	// was previously associated with the stack. If no role is available, AWS
171	// CloudFormation uses a temporary session that is generated from your user
172	// credentials.
173	RoleARN *string
174
175	// The rollback triggers for AWS CloudFormation to monitor during stack creation
176	// and updating operations, and for the specified monitoring period afterwards.
177	RollbackConfiguration *types.RollbackConfiguration
178
179	// Structure containing a new stack policy body. You can specify either the
180	// StackPolicyBody or the StackPolicyURL parameter, but not both. You might update
181	// the stack policy, for example, in order to protect a new resource that you
182	// created during a stack update. If you do not specify a stack policy, the current
183	// policy that is associated with the stack is unchanged.
184	StackPolicyBody *string
185
186	// Structure containing the temporary overriding stack policy body. You can specify
187	// either the StackPolicyDuringUpdateBody or the StackPolicyDuringUpdateURL
188	// parameter, but not both. If you want to update protected resources, specify a
189	// temporary overriding stack policy during this update. If you do not specify a
190	// stack policy, the current policy that is associated with the stack will be used.
191	StackPolicyDuringUpdateBody *string
192
193	// Location of a file containing the temporary overriding stack policy. The URL
194	// must point to a policy (max size: 16KB) located in an S3 bucket in the same
195	// Region as the stack. You can specify either the StackPolicyDuringUpdateBody or
196	// the StackPolicyDuringUpdateURL parameter, but not both. If you want to update
197	// protected resources, specify a temporary overriding stack policy during this
198	// update. If you do not specify a stack policy, the current policy that is
199	// associated with the stack will be used.
200	StackPolicyDuringUpdateURL *string
201
202	// Location of a file containing the updated stack policy. The URL must point to a
203	// policy (max size: 16KB) located in an S3 bucket in the same Region as the stack.
204	// You can specify either the StackPolicyBody or the StackPolicyURL parameter, but
205	// not both. You might update the stack policy, for example, in order to protect a
206	// new resource that you created during a stack update. If you do not specify a
207	// stack policy, the current policy that is associated with the stack is unchanged.
208	StackPolicyURL *string
209
210	// Key-value pairs to associate with this stack. AWS CloudFormation also propagates
211	// these tags to supported resources in the stack. You can specify a maximum number
212	// of 50 tags. If you don't specify this parameter, AWS CloudFormation doesn't
213	// modify the stack's tags. If you specify an empty value, AWS CloudFormation
214	// removes all associated tags.
215	Tags []types.Tag
216
217	// Structure containing the template body with a minimum length of 1 byte and a
218	// maximum length of 51,200 bytes. (For more information, go to Template Anatomy
219	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)
220	// in the AWS CloudFormation User Guide.) Conditional: You must specify only one of
221	// the following parameters: TemplateBody, TemplateURL, or set the
222	// UsePreviousTemplate to true.
223	TemplateBody *string
224
225	// Location of file containing the template body. The URL must point to a template
226	// that is located in an Amazon S3 bucket or a Systems Manager document. For more
227	// information, go to Template Anatomy
228	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)
229	// in the AWS CloudFormation User Guide. Conditional: You must specify only one of
230	// the following parameters: TemplateBody, TemplateURL, or set the
231	// UsePreviousTemplate to true.
232	TemplateURL *string
233
234	// Reuse the existing template that is associated with the stack that you are
235	// updating. Conditional: You must specify only one of the following parameters:
236	// TemplateBody, TemplateURL, or set the UsePreviousTemplate to true.
237	UsePreviousTemplate *bool
238}
239
240// The output for an UpdateStack action.
241type UpdateStackOutput struct {
242
243	// Unique identifier of the stack.
244	StackId *string
245
246	// Metadata pertaining to the operation's result.
247	ResultMetadata middleware.Metadata
248}
249
250func addOperationUpdateStackMiddlewares(stack *middleware.Stack, options Options) (err error) {
251	err = stack.Serialize.Add(&awsAwsquery_serializeOpUpdateStack{}, middleware.After)
252	if err != nil {
253		return err
254	}
255	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpUpdateStack{}, middleware.After)
256	if err != nil {
257		return err
258	}
259	if err = addSetLoggerMiddleware(stack, options); err != nil {
260		return err
261	}
262	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
263		return err
264	}
265	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
266		return err
267	}
268	if err = addResolveEndpointMiddleware(stack, options); err != nil {
269		return err
270	}
271	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
272		return err
273	}
274	if err = addRetryMiddlewares(stack, options); err != nil {
275		return err
276	}
277	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
278		return err
279	}
280	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
281		return err
282	}
283	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
284		return err
285	}
286	if err = addClientUserAgent(stack); err != nil {
287		return err
288	}
289	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
290		return err
291	}
292	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
293		return err
294	}
295	if err = addOpUpdateStackValidationMiddleware(stack); err != nil {
296		return err
297	}
298	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateStack(options.Region), middleware.Before); err != nil {
299		return err
300	}
301	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
302		return err
303	}
304	if err = addResponseErrorMiddleware(stack); err != nil {
305		return err
306	}
307	if err = addRequestResponseLogging(stack, options); err != nil {
308		return err
309	}
310	return nil
311}
312
313func newServiceMetadataMiddleware_opUpdateStack(region string) *awsmiddleware.RegisterServiceMetadata {
314	return &awsmiddleware.RegisterServiceMetadata{
315		Region:        region,
316		ServiceID:     ServiceID,
317		SigningName:   "cloudformation",
318		OperationName: "UpdateStack",
319	}
320}
321