Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws_cloud_cost_cur2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ Use `--private` to prevent granting public access (useful for testing):
./release.sh <bucket_name> --private
```

The template will be available at `s3://<bucket_name>/aws_cloud_cost_cur2/v0.0.1/main.yaml`.
The template will be available at `s3://<bucket_name>/aws_cloud_cost_cur2/v0.0.2/main.yaml`.
13 changes: 6 additions & 7 deletions aws_cloud_cost_cur2/datadog_ccm_api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def get_datadog_account_uuid(event):
return None, f"Failed to get account: {e.code} - {error_body}"


def patch_ccm_config(event, uuid):
"""PATCH the Datadog account with CCM data export config."""
def create_ccm_config(event, uuid):
"""Create CCM config using the dedicated CCM config endpoint."""
api_key = event["ResourceProperties"]["APIKey"]
app_key = event["ResourceProperties"]["APPKey"]
api_url = event["ResourceProperties"]["ApiURL"]
Expand All @@ -50,7 +50,7 @@ def patch_ccm_config(event, uuid):
report_name = event["ResourceProperties"]["ReportName"]
report_prefix = event["ResourceProperties"]["ReportPrefix"]

url = f"https://api.{api_url}/api/v2/integration/aws/accounts/{uuid}"
url = f"https://api.{api_url}/api/v2/integration/aws/accounts/{uuid}/ccm_config"
headers = {
"DD-API-KEY": api_key,
"DD-APPLICATION-KEY": app_key,
Expand Down Expand Up @@ -79,8 +79,7 @@ def patch_ccm_config(event, uuid):
}

data = json.dumps(payload).encode("utf-8")
request = urllib.request.Request(url, data=data, headers=headers)
request.get_method = lambda: "PATCH"
request = urllib.request.Request(url, data=data, headers=headers, method="POST")

try:
response = urllib.request.urlopen(request)
Expand Down Expand Up @@ -110,8 +109,8 @@ def handler(event, context):

LOGGER.info(f"Found Datadog account UUID: {uuid}")

# PATCH the CCM config
status_code, response_data = patch_ccm_config(event, uuid)
# Create the CCM config using the dedicated endpoint
status_code, response_data = create_ccm_config(event, uuid)

if status_code == 200:
LOGGER.info("Successfully configured CCM data export")
Expand Down
2 changes: 1 addition & 1 deletion aws_cloud_cost_cur2/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.1
v0.0.2
Loading