Skip to content

Commit

Permalink
feat(client-synthetics): Add support to toggle if a canary will autom…
Browse files Browse the repository at this point in the history
…atically delete provisioned canary resources such as Lambda functions and layers when a canary is deleted. This behavior can be controlled via the new ProvisionedResourceCleanup property exposed in the CreateCanary and UpdateCanary APIs.
  • Loading branch information
awstools committed Nov 7, 2024
1 parent ef8b258 commit b06511c
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 8 deletions.
2 changes: 2 additions & 0 deletions clients/client-synthetics/src/commands/CreateCanaryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface CreateCanaryCommandOutput extends CreateCanaryResponse, __Metad
* ResourcesToReplicateTags: [ // ResourceList
* "lambda-function",
* ],
* ProvisionedResourceCleanup: "AUTOMATIC" || "OFF",
* Tags: { // TagMap
* "<keys>": "STRING_VALUE",
* },
Expand Down Expand Up @@ -151,6 +152,7 @@ export interface CreateCanaryCommandOutput extends CreateCanaryResponse, __Metad
* // ],
* // BaseCanaryRunId: "STRING_VALUE",
* // },
* // ProvisionedResourceCleanup: "AUTOMATIC" || "OFF",
* // Tags: { // TagMap
* // "<keys>": "STRING_VALUE",
* // },
Expand Down
6 changes: 3 additions & 3 deletions clients/client-synthetics/src/commands/DeleteCanaryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export interface DeleteCanaryCommandOutput extends DeleteCanaryResponse, __Metad

/**
* <p>Permanently deletes the specified canary.</p>
* <p>If you specify <code>DeleteLambda</code> to <code>true</code>, CloudWatch Synthetics also deletes
* <p>If the canary's <code>ProvisionedResourceCleanup</code> field is set to <code>AUTOMATIC</code>
* or you specify <code>DeleteLambda</code> in this operation as <code>true</code>, CloudWatch Synthetics also deletes
* the Lambda functions and layers that are used by the canary.</p>
* <p>Other resources used and created by the canary are not automatically deleted.
* After you delete a canary that you do not intend to
* use again, you
* After you delete a canary, you
* should also delete the following:</p>
* <ul>
* <li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface DescribeCanariesCommandOutput extends DescribeCanariesResponse,
* // ],
* // BaseCanaryRunId: "STRING_VALUE",
* // },
* // ProvisionedResourceCleanup: "AUTOMATIC" || "OFF",
* // Tags: { // TagMap
* // "<keys>": "STRING_VALUE",
* // },
Expand Down
1 change: 1 addition & 0 deletions clients/client-synthetics/src/commands/GetCanaryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface GetCanaryCommandOutput extends GetCanaryResponse, __MetadataBea
* // ],
* // BaseCanaryRunId: "STRING_VALUE",
* // },
* // ProvisionedResourceCleanup: "AUTOMATIC" || "OFF",
* // Tags: { // TagMap
* // "<keys>": "STRING_VALUE",
* // },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface UpdateCanaryCommandOutput extends UpdateCanaryResponse, __Metad
* KmsKeyArn: "STRING_VALUE",
* },
* },
* ProvisionedResourceCleanup: "AUTOMATIC" || "OFF",
* };
* const command = new UpdateCanaryCommand(input);
* const response = await client.send(command);
Expand Down
54 changes: 52 additions & 2 deletions clients/client-synthetics/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,21 @@ export interface CanaryCodeOutput {
Handler?: string;
}

/**
* @public
* @enum
*/
export const ProvisionedResourceCleanupSetting = {
AUTOMATIC: "AUTOMATIC",
OFF: "OFF",
} as const;

/**
* @public
*/
export type ProvisionedResourceCleanupSetting =
(typeof ProvisionedResourceCleanupSetting)[keyof typeof ProvisionedResourceCleanupSetting];

/**
* <p>A structure that contains information about a canary run.</p>
* @public
Expand Down Expand Up @@ -588,6 +603,17 @@ export interface Canary {
*/
VisualReference?: VisualReferenceOutput;

/**
* <p>Specifies whether to also delete the Lambda functions and layers used by this canary
* when the canary is deleted. If it is <code>AUTOMATIC</code>, the Lambda functions and layers will be deleted
* when the canary is deleted.</p>
* <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter
* of the <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html">DeleteCanary</a> operation
* determines whether the Lambda functions and layers will be deleted.</p>
* @public
*/
ProvisionedResourceCleanup?: ProvisionedResourceCleanupSetting;

/**
* <p>The list of key-value pairs that are associated with the canary.</p>
* @public
Expand Down Expand Up @@ -1054,11 +1080,22 @@ export interface CreateCanaryRequest {
* <p>To have the tags that you apply to this canary also be applied to the Lambda function that
* the canary uses, specify this parameter with the value <code>lambda-function</code>.</p>
* <p>If you specify this parameter and don't specify any tags in the <code>Tags</code>
* parameter, the canary creation fails.</p>
* parameter, the canary creation fails.</p>
* @public
*/
ResourcesToReplicateTags?: ResourceToTag[];

/**
* <p>Specifies whether to also delete the Lambda functions and layers used by this canary
* when the canary is deleted. If you omit this parameter, the default of <code>AUTOMATIC</code> is used, which means
* that the Lambda functions and layers will be deleted when the canary is deleted.</p>
* <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter
* of the <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html">DeleteCanary</a> operation
* determines whether the Lambda functions and layers will be deleted.</p>
* @public
*/
ProvisionedResourceCleanup?: ProvisionedResourceCleanupSetting;

/**
* <p>A list of key-value pairs to associate with the canary.
* You can associate as many as 50 tags with a canary.</p>
Expand Down Expand Up @@ -1201,7 +1238,10 @@ export interface DeleteCanaryRequest {

/**
* <p>Specifies whether to also delete the Lambda functions and layers used by this canary. The default
* is false.</p>
* is <code>false</code>.</p>
* <p>Your setting for this parameter is used only if the canary doesn't have <code>AUTOMATIC</code> for its
* <code>ProvisionedResourceCleanup</code> field. If that field is set to <code>AUTOMATIC</code>, then the
* Lambda functions and layers will be deleted when this canary is deleted. </p>
* <p>Type: Boolean</p>
* @public
*/
Expand Down Expand Up @@ -2037,6 +2077,16 @@ export interface UpdateCanaryRequest {
* @public
*/
ArtifactConfig?: ArtifactConfigInput;

/**
* <p>Specifies whether to also delete the Lambda functions and layers used by this canary
* when the canary is deleted.</p>
* <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter
* of the <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html">DeleteCanary</a> operation
* determines whether the Lambda functions and layers will be deleted.</p>
* @public
*/
ProvisionedResourceCleanup?: ProvisionedResourceCleanupSetting;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions clients/client-synthetics/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const se_CreateCanaryCommand = async (
ExecutionRoleArn: [],
FailureRetentionPeriodInDays: [],
Name: [],
ProvisionedResourceCleanup: [],
ResourcesToReplicateTags: (_) => _json(_),
RunConfig: (_) => _json(_),
RuntimeVersion: [],
Expand Down Expand Up @@ -537,6 +538,7 @@ export const se_UpdateCanaryCommand = async (
Code: (_) => se_CanaryCodeInput(_, context),
ExecutionRoleArn: [],
FailureRetentionPeriodInDays: [],
ProvisionedResourceCleanup: [],
RunConfig: (_) => _json(_),
RuntimeVersion: [],
Schedule: (_) => _json(_),
Expand Down Expand Up @@ -1290,6 +1292,7 @@ const de_Canary = (output: any, context: __SerdeContext): Canary => {
FailureRetentionPeriodInDays: __expectInt32,
Id: __expectString,
Name: __expectString,
ProvisionedResourceCleanup: __expectString,
RunConfig: _json,
RuntimeVersion: __expectString,
Schedule: _json,
Expand Down
41 changes: 38 additions & 3 deletions codegen/sdk-codegen/aws-models/synthetics.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
"smithy.api#documentation": "<p>If this canary performs visual monitoring by comparing screenshots, this structure contains the ID of the canary run to use as the baseline for screenshots, and the coordinates\n of any parts of the screen to ignore during the visual monitoring comparison.</p>"
}
},
"ProvisionedResourceCleanup": {
"target": "com.amazonaws.synthetics#ProvisionedResourceCleanupSetting",
"traits": {
"smithy.api#documentation": "<p>Specifies whether to also delete the Lambda functions and layers used by this canary\n when the canary is deleted. If it is <code>AUTOMATIC</code>, the Lambda functions and layers will be deleted\n when the canary is deleted.</p>\n <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter\n of the <a href=\"https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html\">DeleteCanary</a> operation\n determines whether the Lambda functions and layers will be deleted.</p>"
}
},
"Tags": {
"target": "com.amazonaws.synthetics#TagMap",
"traits": {
Expand Down Expand Up @@ -946,7 +952,13 @@
"ResourcesToReplicateTags": {
"target": "com.amazonaws.synthetics#ResourceList",
"traits": {
"smithy.api#documentation": "<p>To have the tags that you apply to this canary also be applied to the Lambda function that\n the canary uses, specify this parameter with the value <code>lambda-function</code>.</p>\n <p>If you specify this parameter and don't specify any tags in the <code>Tags</code>\n parameter, the canary creation fails.</p>"
"smithy.api#documentation": "<p>To have the tags that you apply to this canary also be applied to the Lambda function that\n the canary uses, specify this parameter with the value <code>lambda-function</code>.</p>\n <p>If you specify this parameter and don't specify any tags in the <code>Tags</code>\n parameter, the canary creation fails.</p>"
}
},
"ProvisionedResourceCleanup": {
"target": "com.amazonaws.synthetics#ProvisionedResourceCleanupSetting",
"traits": {
"smithy.api#documentation": "<p>Specifies whether to also delete the Lambda functions and layers used by this canary\n when the canary is deleted. If you omit this parameter, the default of <code>AUTOMATIC</code> is used, which means\n that the Lambda functions and layers will be deleted when the canary is deleted.</p>\n <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter\n of the <a href=\"https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html\">DeleteCanary</a> operation\n determines whether the Lambda functions and layers will be deleted.</p>"
}
},
"Tags": {
Expand Down Expand Up @@ -1069,7 +1081,7 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Permanently deletes the specified canary.</p>\n <p>If you specify <code>DeleteLambda</code> to <code>true</code>, CloudWatch Synthetics also deletes\n the Lambda functions and layers that are used by the canary.</p>\n <p>Other resources used and created by the canary are not automatically deleted. \n After you delete a canary that you do not intend to\n use again, you\n should also delete the following:</p>\n <ul>\n <li>\n <p>The CloudWatch alarms created for this canary. These alarms have a name of\n <code>Synthetics-Alarm-<i>first-198-characters-of-canary-name</i>-<i>canaryId</i>-<i>alarm number</i>\n </code>\n </p>\n </li>\n <li>\n <p>Amazon S3 objects and buckets, such as the canary's artifact location.</p>\n </li>\n <li>\n <p>IAM roles created for the canary. If they were created in the console, these roles\n have the name <code>\n role/service-role/CloudWatchSyntheticsRole-<i>First-21-Characters-of-CanaryName</i>\n </code>\n </p>\n </li>\n <li>\n <p>CloudWatch Logs log groups created for the canary. These logs groups have the name\n <code>/aws/lambda/cwsyn-<i>First-21-Characters-of-CanaryName</i>\n </code>\n </p>\n </li>\n </ul>\n <p>Before you delete a canary, you might want to use <code>GetCanary</code> to display\n the information about this canary. Make\n note of the information returned by this operation so that you can delete these resources\n after you delete the canary.</p>",
"smithy.api#documentation": "<p>Permanently deletes the specified canary.</p>\n <p>If the canary's <code>ProvisionedResourceCleanup</code> field is set to <code>AUTOMATIC</code> \n or you specify <code>DeleteLambda</code> in this operation as <code>true</code>, CloudWatch Synthetics also deletes\n the Lambda functions and layers that are used by the canary.</p>\n <p>Other resources used and created by the canary are not automatically deleted. \n After you delete a canary, you\n should also delete the following:</p>\n <ul>\n <li>\n <p>The CloudWatch alarms created for this canary. These alarms have a name of\n <code>Synthetics-Alarm-<i>first-198-characters-of-canary-name</i>-<i>canaryId</i>-<i>alarm number</i>\n </code>\n </p>\n </li>\n <li>\n <p>Amazon S3 objects and buckets, such as the canary's artifact location.</p>\n </li>\n <li>\n <p>IAM roles created for the canary. If they were created in the console, these roles\n have the name <code>\n role/service-role/CloudWatchSyntheticsRole-<i>First-21-Characters-of-CanaryName</i>\n </code>\n </p>\n </li>\n <li>\n <p>CloudWatch Logs log groups created for the canary. These logs groups have the name\n <code>/aws/lambda/cwsyn-<i>First-21-Characters-of-CanaryName</i>\n </code>\n </p>\n </li>\n </ul>\n <p>Before you delete a canary, you might want to use <code>GetCanary</code> to display\n the information about this canary. Make\n note of the information returned by this operation so that you can delete these resources\n after you delete the canary.</p>",
"smithy.api#http": {
"method": "DELETE",
"uri": "/canary/{Name}",
Expand All @@ -1092,7 +1104,7 @@
"target": "com.amazonaws.synthetics#boolean",
"traits": {
"smithy.api#default": false,
"smithy.api#documentation": "<p>Specifies whether to also delete the Lambda functions and layers used by this canary. The default\n is false.</p>\n <p>Type: Boolean</p>",
"smithy.api#documentation": "<p>Specifies whether to also delete the Lambda functions and layers used by this canary. The default\n is <code>false</code>.</p>\n <p>Your setting for this parameter is used only if the canary doesn't have <code>AUTOMATIC</code> for its \n <code>ProvisionedResourceCleanup</code> field. If that field is set to <code>AUTOMATIC</code>, then the \n Lambda functions and layers will be deleted when this canary is deleted. </p>\n <p>Type: Boolean</p>",
"smithy.api#httpQuery": "deleteLambda"
}
}
Expand Down Expand Up @@ -2242,6 +2254,23 @@
"smithy.api#pattern": "^.+$"
}
},
"com.amazonaws.synthetics#ProvisionedResourceCleanupSetting": {
"type": "enum",
"members": {
"AUTOMATIC": {
"target": "smithy.api#Unit",
"traits": {
"smithy.api#enumValue": "AUTOMATIC"
}
},
"OFF": {
"target": "smithy.api#Unit",
"traits": {
"smithy.api#enumValue": "OFF"
}
}
}
},
"com.amazonaws.synthetics#RequestEntityTooLargeException": {
"type": "structure",
"members": {
Expand Down Expand Up @@ -3914,6 +3943,12 @@
"traits": {
"smithy.api#documentation": "<p>A structure that contains the configuration for canary artifacts, \n including the encryption-at-rest settings for artifacts that \n the canary uploads to Amazon S3.</p>"
}
},
"ProvisionedResourceCleanup": {
"target": "com.amazonaws.synthetics#ProvisionedResourceCleanupSetting",
"traits": {
"smithy.api#documentation": "<p>Specifies whether to also delete the Lambda functions and layers used by this canary\n when the canary is deleted.</p>\n <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter\n of the <a href=\"https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html\">DeleteCanary</a> operation\n determines whether the Lambda functions and layers will be deleted.</p>"
}
}
},
"traits": {
Expand Down

0 comments on commit b06511c

Please sign in to comment.