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