1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
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// Changes the default customer master key (CMK) for EBS encryption by default for
14// your account in this Region. AWS creates a unique AWS managed CMK in each Region
15// for use with encryption by default. If you change the default CMK to a symmetric
16// customer managed CMK, it is used instead of the AWS managed CMK. To reset the
17// default CMK to the AWS managed CMK for EBS, use ResetEbsDefaultKmsKeyId. Amazon
18// EBS does not support asymmetric CMKs. If you delete or disable the customer
19// managed CMK that you specified for use with encryption by default, your
20// instances will fail to launch. For more information, see Amazon EBS encryption
21// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html) in the
22// Amazon Elastic Compute Cloud User Guide.
23func (c *Client) ModifyEbsDefaultKmsKeyId(ctx context.Context, params *ModifyEbsDefaultKmsKeyIdInput, optFns ...func(*Options)) (*ModifyEbsDefaultKmsKeyIdOutput, error) {
24	if params == nil {
25		params = &ModifyEbsDefaultKmsKeyIdInput{}
26	}
27
28	result, metadata, err := c.invokeOperation(ctx, "ModifyEbsDefaultKmsKeyId", params, optFns, addOperationModifyEbsDefaultKmsKeyIdMiddlewares)
29	if err != nil {
30		return nil, err
31	}
32
33	out := result.(*ModifyEbsDefaultKmsKeyIdOutput)
34	out.ResultMetadata = metadata
35	return out, nil
36}
37
38type ModifyEbsDefaultKmsKeyIdInput struct {
39
40	// The identifier of the AWS Key Management Service (AWS KMS) customer master key
41	// (CMK) to use for Amazon EBS encryption. If this parameter is not specified, your
42	// AWS managed CMK for EBS is used. If KmsKeyId is specified, the encrypted state
43	// must be true. You can specify the CMK using any of the following:
44	//
45	// * Key ID. For
46	// example, 1234abcd-12ab-34cd-56ef-1234567890ab.
47	//
48	// * Key alias. For example,
49	// alias/ExampleAlias.
50	//
51	// * Key ARN. For example,
52	// arn:aws:kms:us-east-1:012345678910:key/1234abcd-12ab-34cd-56ef-1234567890ab.
53	//
54	// *
55	// Alias ARN. For example,
56	// arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.
57	//
58	// AWS authenticates the
59	// CMK asynchronously. Therefore, if you specify an ID, alias, or ARN that is not
60	// valid, the action can appear to complete, but eventually fails. Amazon EBS does
61	// not support asymmetric CMKs.
62	//
63	// This member is required.
64	KmsKeyId *string
65
66	// Checks whether you have the required permissions for the action, without
67	// actually making the request, and provides an error response. If you have the
68	// required permissions, the error response is DryRunOperation. Otherwise, it is
69	// UnauthorizedOperation.
70	DryRun bool
71}
72
73type ModifyEbsDefaultKmsKeyIdOutput struct {
74
75	// The Amazon Resource Name (ARN) of the default CMK for encryption by default.
76	KmsKeyId *string
77
78	// Metadata pertaining to the operation's result.
79	ResultMetadata middleware.Metadata
80}
81
82func addOperationModifyEbsDefaultKmsKeyIdMiddlewares(stack *middleware.Stack, options Options) (err error) {
83	err = stack.Serialize.Add(&awsEc2query_serializeOpModifyEbsDefaultKmsKeyId{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	err = stack.Deserialize.Add(&awsEc2query_deserializeOpModifyEbsDefaultKmsKeyId{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	if err = addSetLoggerMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
95		return err
96	}
97	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
98		return err
99	}
100	if err = addResolveEndpointMiddleware(stack, options); err != nil {
101		return err
102	}
103	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
104		return err
105	}
106	if err = addRetryMiddlewares(stack, options); err != nil {
107		return err
108	}
109	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
113		return err
114	}
115	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
116		return err
117	}
118	if err = addClientUserAgent(stack); err != nil {
119		return err
120	}
121	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addOpModifyEbsDefaultKmsKeyIdValidationMiddleware(stack); err != nil {
128		return err
129	}
130	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opModifyEbsDefaultKmsKeyId(options.Region), middleware.Before); err != nil {
131		return err
132	}
133	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResponseErrorMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addRequestResponseLogging(stack, options); err != nil {
140		return err
141	}
142	return nil
143}
144
145func newServiceMetadataMiddleware_opModifyEbsDefaultKmsKeyId(region string) *awsmiddleware.RegisterServiceMetadata {
146	return &awsmiddleware.RegisterServiceMetadata{
147		Region:        region,
148		ServiceID:     ServiceID,
149		SigningName:   "ec2",
150		OperationName: "ModifyEbsDefaultKmsKeyId",
151	}
152}
153