Skip to content

Commit 489e71a

Browse files
committed
mark fields as required and add back change check
1 parent 04353e4 commit 489e71a

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

datadog-integrations-awsaccount-handler/datadog-integrations-awsaccount.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
"description": "Your Datadog role delegation name.",
5858
"type": "string"
5959
}
60-
}
60+
},
61+
"required": [
62+
"RoleName"
63+
]
6164
},
6265
"AWSRegions": {
6366
"description": "The configuration for which regions to collect data from.",
@@ -247,7 +250,10 @@
247250
"type": "string"
248251
}
249252
},
250-
"required": [],
253+
"required": [
254+
"AuthConfig",
255+
"AWSPartition"
256+
],
251257
"primaryIdentifier": [
252258
"/properties/Id"
253259
],

datadog-integrations-awsaccount-handler/docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ _Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/l
6060

6161
The AWS partition to use. This should be set to 'aws' for commercial accounts, 'aws-us-gov' for GovCloud accounts, and 'aws-cn' for China accounts.
6262

63-
_Required_: No
63+
_Required_: Yes
6464

6565
_Type_: String
6666

@@ -72,7 +72,7 @@ _Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormati
7272

7373
The configuration for the AWS role delegation.
7474

75-
_Required_: No
75+
_Required_: Yes
7676

7777
_Type_: <a href="authconfig.md">AuthConfig</a>
7878

datadog-integrations-awsaccount-handler/docs/authconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To declare this entity in your AWS CloudFormation template, use the following sy
2626

2727
Your Datadog role delegation name.
2828

29-
_Required_: No
29+
_Required_: Yes
3030

3131
_Type_: String
3232

datadog-integrations-awsaccount-handler/src/datadog_integrations_awsaccount/handlers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def update_handler(
291291
callback_context: MutableMapping[str, Any],
292292
) -> ProgressEvent:
293293
LOG.info("Starting %s Update Handler", TYPE_NAME)
294+
previousState = request.previousResourceState
294295
model = request.desiredResourceState
295296
type_configuration = request.typeConfiguration
296297

@@ -303,6 +304,23 @@ def update_handler(
303304
errorCode=HandlerErrorCode.NotFound,
304305
)
305306

307+
# Check if createOnly fields are being updated
308+
if previousState.AccountID != model.AccountID:
309+
return ProgressEvent(
310+
status=OperationStatus.FAILED,
311+
resourceModel=model,
312+
message="Cannot update `AccountID`. Please delete it and create a new one instead.",
313+
errorCode=HandlerErrorCode.NotUpdatable,
314+
)
315+
if previousState.AuthConfig and model.AuthConfig:
316+
if previousState.AuthConfig.RoleName != model.AuthConfig.RoleName:
317+
return ProgressEvent(
318+
status=OperationStatus.FAILED,
319+
resourceModel=model,
320+
message="Cannot update `AuthConfig.RoleName`. Please delete it and create a new one instead.",
321+
errorCode=HandlerErrorCode.NotUpdatable,
322+
)
323+
306324
aws_account = build_api_request_from_model(AWSAccountUpdateRequestAttributes, model)
307325

308326
with client(

0 commit comments

Comments
 (0)