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// Detect drift on a stack set. When CloudFormation performs drift detection on a 16// stack set, it performs drift detection on the stack associated with each stack 17// instance in the stack set. For more information, see How CloudFormation Performs 18// Drift Detection on a Stack Set 19// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-drift.html). 20// DetectStackSetDrift returns the OperationId of the stack set drift detection 21// operation. Use this operation id with DescribeStackSetOperation to monitor the 22// progress of the drift detection operation. The drift detection operation may 23// take some time, depending on the number of stack instances included in the stack 24// set, as well as the number of resources included in each stack. Once the 25// operation has completed, use the following actions to return drift 26// information: 27// 28// * Use DescribeStackSet to return detailed information about the 29// stack set, including detailed information about the last completed drift 30// operation performed on the stack set. (Information about drift operations that 31// are in progress is not included.) 32// 33// * Use ListStackInstances to return a list of 34// stack instances belonging to the stack set, including the drift status and last 35// drift time checked of each instance. 36// 37// * Use DescribeStackInstance to return 38// detailed information about a specific stack instance, including its drift status 39// and last drift time checked. 40// 41// For more information on performing a drift 42// detection operation on a stack set, see Detecting Unmanaged Changes in Stack 43// Sets 44// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-drift.html). 45// You can only run a single drift detection operation on a given stack set at one 46// time. To stop a drift detection stack set operation, use StopStackSetOperation. 47func (c *Client) DetectStackSetDrift(ctx context.Context, params *DetectStackSetDriftInput, optFns ...func(*Options)) (*DetectStackSetDriftOutput, error) { 48 if params == nil { 49 params = &DetectStackSetDriftInput{} 50 } 51 52 result, metadata, err := c.invokeOperation(ctx, "DetectStackSetDrift", params, optFns, addOperationDetectStackSetDriftMiddlewares) 53 if err != nil { 54 return nil, err 55 } 56 57 out := result.(*DetectStackSetDriftOutput) 58 out.ResultMetadata = metadata 59 return out, nil 60} 61 62type DetectStackSetDriftInput struct { 63 64 // The name of the stack set on which to perform the drift detection operation. 65 // 66 // This member is required. 67 StackSetName *string 68 69 // [Service-managed permissions] Specifies whether you are acting as an account 70 // administrator in the organization's management account or as a delegated 71 // administrator in a member account. By default, SELF is specified. Use SELF for 72 // stack sets with self-managed permissions. 73 // 74 // * If you are signed in to the 75 // management account, specify SELF. 76 // 77 // * If you are signed in to a delegated 78 // administrator account, specify DELEGATED_ADMIN. Your AWS account must be 79 // registered as a delegated administrator in the management account. For more 80 // information, see Register a delegated administrator 81 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html) 82 // in the AWS CloudFormation User Guide. 83 CallAs types.CallAs 84 85 // The ID of the stack set operation. 86 OperationId *string 87 88 // The user-specified preferences for how AWS CloudFormation performs a stack set 89 // operation. For more information on maximum concurrent accounts and failure 90 // tolerance, see Stack set operation options 91 // (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html#stackset-ops-options). 92 OperationPreferences *types.StackSetOperationPreferences 93} 94 95type DetectStackSetDriftOutput struct { 96 97 // The ID of the drift detection stack set operation. you can use this operation id 98 // with DescribeStackSetOperation to monitor the progress of the drift detection 99 // operation. 100 OperationId *string 101 102 // Metadata pertaining to the operation's result. 103 ResultMetadata middleware.Metadata 104} 105 106func addOperationDetectStackSetDriftMiddlewares(stack *middleware.Stack, options Options) (err error) { 107 err = stack.Serialize.Add(&awsAwsquery_serializeOpDetectStackSetDrift{}, middleware.After) 108 if err != nil { 109 return err 110 } 111 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDetectStackSetDrift{}, middleware.After) 112 if err != nil { 113 return err 114 } 115 if err = addSetLoggerMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 119 return err 120 } 121 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResolveEndpointMiddleware(stack, options); err != nil { 125 return err 126 } 127 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 128 return err 129 } 130 if err = addRetryMiddlewares(stack, options); err != nil { 131 return err 132 } 133 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 134 return err 135 } 136 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 140 return err 141 } 142 if err = addClientUserAgent(stack); err != nil { 143 return err 144 } 145 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 146 return err 147 } 148 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 149 return err 150 } 151 if err = addIdempotencyToken_opDetectStackSetDriftMiddleware(stack, options); err != nil { 152 return err 153 } 154 if err = addOpDetectStackSetDriftValidationMiddleware(stack); err != nil { 155 return err 156 } 157 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDetectStackSetDrift(options.Region), middleware.Before); err != nil { 158 return err 159 } 160 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 161 return err 162 } 163 if err = addResponseErrorMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addRequestResponseLogging(stack, options); err != nil { 167 return err 168 } 169 return nil 170} 171 172type idempotencyToken_initializeOpDetectStackSetDrift struct { 173 tokenProvider IdempotencyTokenProvider 174} 175 176func (*idempotencyToken_initializeOpDetectStackSetDrift) ID() string { 177 return "OperationIdempotencyTokenAutoFill" 178} 179 180func (m *idempotencyToken_initializeOpDetectStackSetDrift) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 181 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 182) { 183 if m.tokenProvider == nil { 184 return next.HandleInitialize(ctx, in) 185 } 186 187 input, ok := in.Parameters.(*DetectStackSetDriftInput) 188 if !ok { 189 return out, metadata, fmt.Errorf("expected middleware input to be of type *DetectStackSetDriftInput ") 190 } 191 192 if input.OperationId == nil { 193 t, err := m.tokenProvider.GetIdempotencyToken() 194 if err != nil { 195 return out, metadata, err 196 } 197 input.OperationId = &t 198 } 199 return next.HandleInitialize(ctx, in) 200} 201func addIdempotencyToken_opDetectStackSetDriftMiddleware(stack *middleware.Stack, cfg Options) error { 202 return stack.Initialize.Add(&idempotencyToken_initializeOpDetectStackSetDrift{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 203} 204 205func newServiceMetadataMiddleware_opDetectStackSetDrift(region string) *awsmiddleware.RegisterServiceMetadata { 206 return &awsmiddleware.RegisterServiceMetadata{ 207 Region: region, 208 ServiceID: ServiceID, 209 SigningName: "cloudformation", 210 OperationName: "DetectStackSetDrift", 211 } 212} 213