1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package opsworks
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/opsworks/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a clone of a specified stack. For more information, see Clone a Stack
15// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-cloning.html).
16// By default, all parameters are set to the values used by the parent stack.
17// Required Permissions: To use this action, an IAM user must have an attached
18// policy that explicitly grants permissions. For more information about user
19// permissions, see Managing User Permissions
20// (https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html).
21func (c *Client) CloneStack(ctx context.Context, params *CloneStackInput, optFns ...func(*Options)) (*CloneStackOutput, error) {
22	if params == nil {
23		params = &CloneStackInput{}
24	}
25
26	result, metadata, err := c.invokeOperation(ctx, "CloneStack", params, optFns, addOperationCloneStackMiddlewares)
27	if err != nil {
28		return nil, err
29	}
30
31	out := result.(*CloneStackOutput)
32	out.ResultMetadata = metadata
33	return out, nil
34}
35
36type CloneStackInput struct {
37
38	// The stack AWS Identity and Access Management (IAM) role, which allows AWS
39	// OpsWorks Stacks to work with AWS resources on your behalf. You must set this
40	// parameter to the Amazon Resource Name (ARN) for an existing IAM role. If you
41	// create a stack by using the AWS OpsWorks Stacks console, it creates the role for
42	// you. You can obtain an existing stack's IAM ARN programmatically by calling
43	// DescribePermissions. For more information about IAM ARNs, see Using Identifiers
44	// (https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html). You
45	// must set this parameter to a valid service role ARN or the action will fail;
46	// there is no default value. You can specify the source stack's service role ARN,
47	// if you prefer, but you must do so explicitly.
48	//
49	// This member is required.
50	ServiceRoleArn *string
51
52	// The source stack ID.
53	//
54	// This member is required.
55	SourceStackId *string
56
57	// The default AWS OpsWorks Stacks agent version. You have the following
58	// options:
59	//
60	// * Auto-update - Set this parameter to LATEST. AWS OpsWorks Stacks
61	// automatically installs new agent versions on the stack's instances as soon as
62	// they are available.
63	//
64	// * Fixed version - Set this parameter to your preferred
65	// agent version. To update the agent version, you must edit the stack
66	// configuration and specify a new version. AWS OpsWorks Stacks then automatically
67	// installs that version on the stack's instances.
68	//
69	// The default setting is LATEST.
70	// To specify an agent version, you must use the complete version number, not the
71	// abbreviated number shown on the console. For a list of available agent version
72	// numbers, call DescribeAgentVersions. AgentVersion cannot be set to Chef 12.2.
73	// You can also specify an agent version when you create or update an instance,
74	// which overrides the stack's default setting.
75	AgentVersion *string
76
77	// A list of stack attributes and values as key/value pairs to be added to the
78	// cloned stack.
79	Attributes map[string]string
80
81	// A ChefConfiguration object that specifies whether to enable Berkshelf and the
82	// Berkshelf version on Chef 11.10 stacks. For more information, see Create a New
83	// Stack
84	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html).
85	ChefConfiguration *types.ChefConfiguration
86
87	// A list of source stack app IDs to be included in the cloned stack.
88	CloneAppIds []string
89
90	// Whether to clone the source stack's permissions.
91	ClonePermissions *bool
92
93	// The configuration manager. When you clone a stack we recommend that you use the
94	// configuration manager to specify the Chef version: 12, 11.10, or 11.4 for Linux
95	// stacks, or 12.2 for Windows stacks. The default value for Linux stacks is
96	// currently 12.
97	ConfigurationManager *types.StackConfigurationManager
98
99	// Contains the information required to retrieve an app or cookbook from a
100	// repository. For more information, see Adding Apps
101	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html)
102	// or Cookbooks and Recipes
103	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook.html).
104	CustomCookbooksSource *types.Source
105
106	// A string that contains user-defined, custom JSON. It is used to override the
107	// corresponding default stack configuration JSON values. The string should be in
108	// the following format: "{\"key1\": \"value1\", \"key2\": \"value2\",...}" For
109	// more information about custom JSON, see Use Custom JSON to Modify the Stack
110	// Configuration Attributes
111	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-json.html)
112	CustomJson *string
113
114	// The cloned stack's default Availability Zone, which must be in the specified
115	// region. For more information, see Regions and Endpoints
116	// (https://docs.aws.amazon.com/general/latest/gr/rande.html). If you also specify
117	// a value for DefaultSubnetId, the subnet must be in the same zone. For more
118	// information, see the VpcId parameter description.
119	DefaultAvailabilityZone *string
120
121	// The Amazon Resource Name (ARN) of an IAM profile that is the default profile for
122	// all of the stack's EC2 instances. For more information about IAM ARNs, see Using
123	// Identifiers
124	// (https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html).
125	DefaultInstanceProfileArn *string
126
127	// The stack's operating system, which must be set to one of the following.
128	//
129	// * A
130	// supported Linux operating system: An Amazon Linux version, such as Amazon Linux
131	// 2018.03, Amazon Linux 2017.09, Amazon Linux 2017.03, Amazon Linux 2016.09,
132	// Amazon Linux 2016.03, Amazon Linux 2015.09, or Amazon Linux 2015.03.
133	//
134	// * A
135	// supported Ubuntu operating system, such as Ubuntu 16.04 LTS, Ubuntu 14.04 LTS,
136	// or Ubuntu 12.04 LTS.
137	//
138	// * CentOS Linux 7
139	//
140	// * Red Hat Enterprise Linux 7
141	//
142	// *
143	// Microsoft Windows Server 2012 R2 Base, Microsoft Windows Server 2012 R2 with SQL
144	// Server Express, Microsoft Windows Server 2012 R2 with SQL Server Standard, or
145	// Microsoft Windows Server 2012 R2 with SQL Server Web.
146	//
147	// * A custom AMI: Custom.
148	// You specify the custom AMI you want to use when you create instances. For more
149	// information about how to use custom AMIs with OpsWorks, see Using Custom AMIs
150	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html).
151	//
152	// The
153	// default option is the parent stack's operating system. For more information
154	// about supported operating systems, see AWS OpsWorks Stacks Operating Systems
155	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html).
156	// You can specify a different Linux operating system for the cloned stack, but you
157	// cannot change from Linux to Windows or Windows to Linux.
158	DefaultOs *string
159
160	// The default root device type. This value is used by default for all instances in
161	// the cloned stack, but you can override it when you create an instance. For more
162	// information, see Storage for the Root Device
163	// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device).
164	DefaultRootDeviceType types.RootDeviceType
165
166	// A default Amazon EC2 key pair name. The default value is none. If you specify a
167	// key pair name, AWS OpsWorks installs the public key on the instance and you can
168	// use the private key with an SSH client to log in to the instance. For more
169	// information, see  Using SSH to Communicate with an Instance
170	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-ssh.html)
171	// and  Managing SSH Access
172	// (https://docs.aws.amazon.com/opsworks/latest/userguide/security-ssh-access.html).
173	// You can override this setting by specifying a different key pair, or no key
174	// pair, when you  create an instance
175	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-add.html).
176	DefaultSshKeyName *string
177
178	// The stack's default VPC subnet ID. This parameter is required if you specify a
179	// value for the VpcId parameter. All instances are launched into this subnet
180	// unless you specify otherwise when you create the instance. If you also specify a
181	// value for DefaultAvailabilityZone, the subnet must be in that zone. For
182	// information on default values and when this parameter is required, see the VpcId
183	// parameter description.
184	DefaultSubnetId *string
185
186	// The stack's host name theme, with spaces are replaced by underscores. The theme
187	// is used to generate host names for the stack's instances. By default,
188	// HostnameTheme is set to Layer_Dependent, which creates host names by appending
189	// integers to the layer's short name. The other themes are:
190	//
191	// * Baked_Goods
192	//
193	// *
194	// Clouds
195	//
196	// * Europe_Cities
197	//
198	// * Fruits
199	//
200	// * Greek_Deities_and_Titans
201	//
202	// *
203	// Legendary_creatures_from_Japan
204	//
205	// * Planets_and_Moons
206	//
207	// * Roman_Deities
208	//
209	// *
210	// Scottish_Islands
211	//
212	// * US_Cities
213	//
214	// * Wild_Cats
215	//
216	// To obtain a generated host name,
217	// call GetHostNameSuggestion, which returns a host name based on the current
218	// theme.
219	HostnameTheme *string
220
221	// The cloned stack name.
222	Name *string
223
224	// The cloned stack AWS region, such as "ap-northeast-2". For more information
225	// about AWS regions, see Regions and Endpoints
226	// (https://docs.aws.amazon.com/general/latest/gr/rande.html).
227	Region *string
228
229	// Whether to use custom cookbooks.
230	UseCustomCookbooks *bool
231
232	// Whether to associate the AWS OpsWorks Stacks built-in security groups with the
233	// stack's layers. AWS OpsWorks Stacks provides a standard set of built-in security
234	// groups, one for each layer, which are associated with layers by default. With
235	// UseOpsworksSecurityGroups you can instead provide your own custom security
236	// groups. UseOpsworksSecurityGroups has the following settings:
237	//
238	// * True - AWS
239	// OpsWorks Stacks automatically associates the appropriate built-in security group
240	// with each layer (default setting). You can associate additional security groups
241	// with a layer after you create it but you cannot delete the built-in security
242	// group.
243	//
244	// * False - AWS OpsWorks Stacks does not associate built-in security
245	// groups with layers. You must create appropriate Amazon Elastic Compute Cloud
246	// (Amazon EC2) security groups and associate a security group with each layer that
247	// you create. However, you can still manually associate a built-in security group
248	// with a layer on creation; custom security groups are required only for those
249	// layers that need custom settings.
250	//
251	// For more information, see Create a New Stack
252	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html).
253	UseOpsworksSecurityGroups *bool
254
255	// The ID of the VPC that the cloned stack is to be launched into. It must be in
256	// the specified region. All instances are launched into this VPC, and you cannot
257	// change the ID later.
258	//
259	// * If your account supports EC2 Classic, the default value
260	// is no VPC.
261	//
262	// * If your account does not support EC2 Classic, the default value is
263	// the default VPC for the specified region.
264	//
265	// If the VPC ID corresponds to a
266	// default VPC and you have specified either the DefaultAvailabilityZone or the
267	// DefaultSubnetId parameter only, AWS OpsWorks Stacks infers the value of the
268	// other parameter. If you specify neither parameter, AWS OpsWorks Stacks sets
269	// these parameters to the first valid Availability Zone for the specified region
270	// and the corresponding default VPC subnet ID, respectively. If you specify a
271	// nondefault VPC ID, note the following:
272	//
273	// * It must belong to a VPC in your
274	// account that is in the specified region.
275	//
276	// * You must specify a value for
277	// DefaultSubnetId.
278	//
279	// For more information about how to use AWS OpsWorks Stacks with
280	// a VPC, see Running a Stack in a VPC
281	// (https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-vpc.html).
282	// For more information about default VPC and EC2 Classic, see Supported Platforms
283	// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-supported-platforms.html).
284	VpcId *string
285}
286
287// Contains the response to a CloneStack request.
288type CloneStackOutput struct {
289
290	// The cloned stack ID.
291	StackId *string
292
293	// Metadata pertaining to the operation's result.
294	ResultMetadata middleware.Metadata
295}
296
297func addOperationCloneStackMiddlewares(stack *middleware.Stack, options Options) (err error) {
298	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCloneStack{}, middleware.After)
299	if err != nil {
300		return err
301	}
302	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCloneStack{}, middleware.After)
303	if err != nil {
304		return err
305	}
306	if err = addSetLoggerMiddleware(stack, options); err != nil {
307		return err
308	}
309	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
310		return err
311	}
312	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
313		return err
314	}
315	if err = addResolveEndpointMiddleware(stack, options); err != nil {
316		return err
317	}
318	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
319		return err
320	}
321	if err = addRetryMiddlewares(stack, options); err != nil {
322		return err
323	}
324	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
325		return err
326	}
327	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
328		return err
329	}
330	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
331		return err
332	}
333	if err = addClientUserAgent(stack); err != nil {
334		return err
335	}
336	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
337		return err
338	}
339	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
340		return err
341	}
342	if err = addOpCloneStackValidationMiddleware(stack); err != nil {
343		return err
344	}
345	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCloneStack(options.Region), middleware.Before); err != nil {
346		return err
347	}
348	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
349		return err
350	}
351	if err = addResponseErrorMiddleware(stack); err != nil {
352		return err
353	}
354	if err = addRequestResponseLogging(stack, options); err != nil {
355		return err
356	}
357	return nil
358}
359
360func newServiceMetadataMiddleware_opCloneStack(region string) *awsmiddleware.RegisterServiceMetadata {
361	return &awsmiddleware.RegisterServiceMetadata{
362		Region:        region,
363		ServiceID:     ServiceID,
364		SigningName:   "opsworks",
365		OperationName: "CloneStack",
366	}
367}
368