api_op_AssociateKmsKey.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  6. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  7. "github.com/aws/smithy-go/middleware"
  8. smithyhttp "github.com/aws/smithy-go/transport/http"
  9. )
  10. // Associates the specified Key Management Service customer master key (CMK) with
  11. // the specified log group. Associating an KMS CMK with a log group overrides any
  12. // existing associations between the log group and a CMK. After a CMK is associated
  13. // with a log group, all newly ingested data for the log group is encrypted using
  14. // the CMK. This association is stored as long as the data encrypted with the CMK
  15. // is still within CloudWatch Logs. This enables CloudWatch Logs to decrypt this
  16. // data whenever it is requested. CloudWatch Logs supports only symmetric CMKs. Do
  17. // not use an associate an asymmetric CMK with your log group. For more
  18. // information, see Using Symmetric and Asymmetric Keys
  19. // (https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html).
  20. // It can take up to 5 minutes for this operation to take effect. If you attempt to
  21. // associate a CMK with a log group but the CMK does not exist or the CMK is
  22. // disabled, you receive an InvalidParameterException error.
  23. func (c *Client) AssociateKmsKey(ctx context.Context, params *AssociateKmsKeyInput, optFns ...func(*Options)) (*AssociateKmsKeyOutput, error) {
  24. if params == nil {
  25. params = &AssociateKmsKeyInput{}
  26. }
  27. result, metadata, err := c.invokeOperation(ctx, "AssociateKmsKey", params, optFns, c.addOperationAssociateKmsKeyMiddlewares)
  28. if err != nil {
  29. return nil, err
  30. }
  31. out := result.(*AssociateKmsKeyOutput)
  32. out.ResultMetadata = metadata
  33. return out, nil
  34. }
  35. type AssociateKmsKeyInput struct {
  36. // The Amazon Resource Name (ARN) of the CMK to use when encrypting log data. This
  37. // must be a symmetric CMK. For more information, see Amazon Resource Names - Key
  38. // Management Service
  39. // (https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kms)
  40. // and Using Symmetric and Asymmetric Keys
  41. // (https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html).
  42. //
  43. // This member is required.
  44. KmsKeyId *string
  45. // The name of the log group.
  46. //
  47. // This member is required.
  48. LogGroupName *string
  49. noSmithyDocumentSerde
  50. }
  51. type AssociateKmsKeyOutput struct {
  52. // Metadata pertaining to the operation's result.
  53. ResultMetadata middleware.Metadata
  54. noSmithyDocumentSerde
  55. }
  56. func (c *Client) addOperationAssociateKmsKeyMiddlewares(stack *middleware.Stack, options Options) (err error) {
  57. err = stack.Serialize.Add(&awsAwsjson11_serializeOpAssociateKmsKey{}, middleware.After)
  58. if err != nil {
  59. return err
  60. }
  61. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAssociateKmsKey{}, middleware.After)
  62. if err != nil {
  63. return err
  64. }
  65. if err = addSetLoggerMiddleware(stack, options); err != nil {
  66. return err
  67. }
  68. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  69. return err
  70. }
  71. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  72. return err
  73. }
  74. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  75. return err
  76. }
  77. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  78. return err
  79. }
  80. if err = addRetryMiddlewares(stack, options); err != nil {
  81. return err
  82. }
  83. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  84. return err
  85. }
  86. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  87. return err
  88. }
  89. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  90. return err
  91. }
  92. if err = addClientUserAgent(stack); err != nil {
  93. return err
  94. }
  95. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  96. return err
  97. }
  98. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  99. return err
  100. }
  101. if err = addOpAssociateKmsKeyValidationMiddleware(stack); err != nil {
  102. return err
  103. }
  104. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAssociateKmsKey(options.Region), middleware.Before); err != nil {
  105. return err
  106. }
  107. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  108. return err
  109. }
  110. if err = addResponseErrorMiddleware(stack); err != nil {
  111. return err
  112. }
  113. if err = addRequestResponseLogging(stack, options); err != nil {
  114. return err
  115. }
  116. return nil
  117. }
  118. func newServiceMetadataMiddleware_opAssociateKmsKey(region string) *awsmiddleware.RegisterServiceMetadata {
  119. return &awsmiddleware.RegisterServiceMetadata{
  120. Region: region,
  121. ServiceID: ServiceID,
  122. SigningName: "logs",
  123. OperationName: "AssociateKmsKey",
  124. }
  125. }