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/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Detects whether a stack's actual configuration differs, or has drifted, from
14// it's expected configuration, as defined in the stack template and any values
15// specified as template parameters. For each resource in the stack that supports
16// drift detection, AWS CloudFormation compares the actual configuration of the
17// resource with its expected template configuration. Only resource properties
18// explicitly defined in the stack template are checked for drift. A stack is
19// considered to have drifted if one or more of its resources differ from their
20// expected template configurations. For more information, see Detecting
21// Unregulated Configuration Changes to Stacks and Resources
22// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html).
23// Use DetectStackDrift to detect drift on all supported resources for a given
24// stack, or DetectStackResourceDrift to detect drift on individual resources. For
25// a list of stack resources that currently support drift detection, see Resources
26// that Support Drift Detection
27// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift-resource-list.html).
28// DetectStackDrift can take up to several minutes, depending on the number of
29// resources contained within the stack. Use DescribeStackDriftDetectionStatus to
30// monitor the progress of a detect stack drift operation. Once the drift detection
31// operation has completed, use DescribeStackResourceDrifts to return drift
32// information about the stack and its resources. When detecting drift on a stack,
33// AWS CloudFormation does not detect drift on any nested stacks belonging to that
34// stack. Perform DetectStackDrift directly on the nested stack itself.
35func (c *Client) DetectStackDrift(ctx context.Context, params *DetectStackDriftInput, optFns ...func(*Options)) (*DetectStackDriftOutput, error) {
36	if params == nil {
37		params = &DetectStackDriftInput{}
38	}
39
40	result, metadata, err := c.invokeOperation(ctx, "DetectStackDrift", params, optFns, addOperationDetectStackDriftMiddlewares)
41	if err != nil {
42		return nil, err
43	}
44
45	out := result.(*DetectStackDriftOutput)
46	out.ResultMetadata = metadata
47	return out, nil
48}
49
50type DetectStackDriftInput struct {
51
52	// The name of the stack for which you want to detect drift.
53	//
54	// This member is required.
55	StackName *string
56
57	// The logical names of any resources you want to use as filters.
58	LogicalResourceIds []string
59}
60
61type DetectStackDriftOutput struct {
62
63	// The ID of the drift detection results of this operation. AWS CloudFormation
64	// generates new results, with a new drift detection ID, each time this operation
65	// is run. However, the number of drift results AWS CloudFormation retains for any
66	// given stack, and for how long, may vary.
67	//
68	// This member is required.
69	StackDriftDetectionId *string
70
71	// Metadata pertaining to the operation's result.
72	ResultMetadata middleware.Metadata
73}
74
75func addOperationDetectStackDriftMiddlewares(stack *middleware.Stack, options Options) (err error) {
76	err = stack.Serialize.Add(&awsAwsquery_serializeOpDetectStackDrift{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDetectStackDrift{}, middleware.After)
81	if err != nil {
82		return err
83	}
84	if err = addSetLoggerMiddleware(stack, options); err != nil {
85		return err
86	}
87	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
88		return err
89	}
90	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
91		return err
92	}
93	if err = addResolveEndpointMiddleware(stack, options); err != nil {
94		return err
95	}
96	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
97		return err
98	}
99	if err = addRetryMiddlewares(stack, options); err != nil {
100		return err
101	}
102	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
109		return err
110	}
111	if err = addClientUserAgent(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = addOpDetectStackDriftValidationMiddleware(stack); err != nil {
121		return err
122	}
123	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDetectStackDrift(options.Region), middleware.Before); err != nil {
124		return err
125	}
126	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addResponseErrorMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addRequestResponseLogging(stack, options); err != nil {
133		return err
134	}
135	return nil
136}
137
138func newServiceMetadataMiddleware_opDetectStackDrift(region string) *awsmiddleware.RegisterServiceMetadata {
139	return &awsmiddleware.RegisterServiceMetadata{
140		Region:        region,
141		ServiceID:     ServiceID,
142		SigningName:   "cloudformation",
143		OperationName: "DetectStackDrift",
144	}
145}
146