1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package cloudformation 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Creates stack instances for the specified accounts, within the specified 16// Regions. A stack instance refers to a stack in a specific account and Region. 17// You must specify at least one value for either Accounts or DeploymentTargets, 18// and you must specify at least one value for Regions. 19func (c *Client) CreateStackInstances(ctx context.Context, params *CreateStackInstancesInput, optFns ...func(*Options)) (*CreateStackInstancesOutput, error) { 20 if params == nil { 21 params = &CreateStackInstancesInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "CreateStackInstances", params, optFns, addOperationCreateStackInstancesMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*CreateStackInstancesOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34type CreateStackInstancesInput struct { 35 36 // The names of one or more Regions where you want to create stack instances using 37 // the specified AWS account(s). 38 // 39 // This member is required. 40 Regions []string 41 42 // The name or unique ID of the stack set that you want to create stack instances 43 // from. 44 // 45 // This member is required. 46 StackSetName *string 47 48 // [Self-managed permissions] The names of one or more AWS accounts that you want 49 // to create stack instances in the specified Region(s) for. You can specify 50 // Accounts or DeploymentTargets, but not both. 51 Accounts []string 52 53 // [Service-managed permissions] The AWS Organizations accounts for which to create 54 // stack instances in the specified Regions. You can specify Accounts or 55 // DeploymentTargets, but not both. 56 DeploymentTargets *types.DeploymentTargets 57 58 // The unique identifier for this stack set operation. The operation ID also 59 // functions as an idempotency token, to ensure that AWS CloudFormation performs 60 // the stack set operation only once, even if you retry the request multiple times. 61 // You might retry stack set operation requests to ensure that AWS CloudFormation 62 // successfully received them. If you don't specify an operation ID, the SDK 63 // generates one automatically. Repeating this stack set operation with a new 64 // operation ID retries all stack instances whose status is OUTDATED. 65 OperationId *string 66 67 // Preferences for how AWS CloudFormation performs this stack set operation. 68 OperationPreferences *types.StackSetOperationPreferences 69 70 // A list of stack set parameters whose values you want to override in the selected 71 // stack instances. Any overridden parameter values will be applied to all stack 72 // instances in the specified accounts and Regions. When specifying parameters and 73 // their values, be aware of how AWS CloudFormation sets parameter values during 74 // stack instance operations: 75 // 76 // * To override the current value for a parameter, 77 // include the parameter and specify its value. 78 // 79 // * To leave a parameter set to its 80 // present value, you can do one of the following: 81 // 82 // * Do not include the parameter 83 // in the list. 84 // 85 // * Include the parameter and specify UsePreviousValue as true. (You 86 // cannot specify both a value and set UsePreviousValue to true.) 87 // 88 // * To set all 89 // overridden parameter back to the values specified in the stack set, specify a 90 // parameter list but do not include any parameters. 91 // 92 // * To leave all parameters set 93 // to their present values, do not specify this property at all. 94 // 95 // During stack set 96 // updates, any parameter values overridden for a stack instance are not updated, 97 // but retain their overridden value. You can only override the parameter values 98 // that are specified in the stack set; to add or delete a parameter itself, use 99 // UpdateStackSet 100 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_UpdateStackSet.html) 101 // to update the stack set template. 102 ParameterOverrides []types.Parameter 103} 104 105type CreateStackInstancesOutput struct { 106 107 // The unique identifier for this stack set operation. 108 OperationId *string 109 110 // Metadata pertaining to the operation's result. 111 ResultMetadata middleware.Metadata 112} 113 114func addOperationCreateStackInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) { 115 err = stack.Serialize.Add(&awsAwsquery_serializeOpCreateStackInstances{}, middleware.After) 116 if err != nil { 117 return err 118 } 119 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpCreateStackInstances{}, middleware.After) 120 if err != nil { 121 return err 122 } 123 if err = addSetLoggerMiddleware(stack, options); err != nil { 124 return err 125 } 126 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 127 return err 128 } 129 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addResolveEndpointMiddleware(stack, options); err != nil { 133 return err 134 } 135 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 136 return err 137 } 138 if err = addRetryMiddlewares(stack, options); err != nil { 139 return err 140 } 141 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 142 return err 143 } 144 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 145 return err 146 } 147 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 148 return err 149 } 150 if err = addClientUserAgent(stack); err != nil { 151 return err 152 } 153 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 154 return err 155 } 156 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 157 return err 158 } 159 if err = addIdempotencyToken_opCreateStackInstancesMiddleware(stack, options); err != nil { 160 return err 161 } 162 if err = addOpCreateStackInstancesValidationMiddleware(stack); err != nil { 163 return err 164 } 165 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateStackInstances(options.Region), middleware.Before); err != nil { 166 return err 167 } 168 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 169 return err 170 } 171 if err = addResponseErrorMiddleware(stack); err != nil { 172 return err 173 } 174 if err = addRequestResponseLogging(stack, options); err != nil { 175 return err 176 } 177 return nil 178} 179 180type idempotencyToken_initializeOpCreateStackInstances struct { 181 tokenProvider IdempotencyTokenProvider 182} 183 184func (*idempotencyToken_initializeOpCreateStackInstances) ID() string { 185 return "OperationIdempotencyTokenAutoFill" 186} 187 188func (m *idempotencyToken_initializeOpCreateStackInstances) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 189 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 190) { 191 if m.tokenProvider == nil { 192 return next.HandleInitialize(ctx, in) 193 } 194 195 input, ok := in.Parameters.(*CreateStackInstancesInput) 196 if !ok { 197 return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateStackInstancesInput ") 198 } 199 200 if input.OperationId == nil { 201 t, err := m.tokenProvider.GetIdempotencyToken() 202 if err != nil { 203 return out, metadata, err 204 } 205 input.OperationId = &t 206 } 207 return next.HandleInitialize(ctx, in) 208} 209func addIdempotencyToken_opCreateStackInstancesMiddleware(stack *middleware.Stack, cfg Options) error { 210 return stack.Initialize.Add(&idempotencyToken_initializeOpCreateStackInstances{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 211} 212 213func newServiceMetadataMiddleware_opCreateStackInstances(region string) *awsmiddleware.RegisterServiceMetadata { 214 return &awsmiddleware.RegisterServiceMetadata{ 215 Region: region, 216 ServiceID: ServiceID, 217 SigningName: "cloudformation", 218 OperationName: "CreateStackInstances", 219 } 220} 221