Skip to content

Commit c00cb0b

Browse files
committed
add a random string to trail bucket name + add logs
1 parent a2572ea commit c00cb0b

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

aws_account_integration/main.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ Resources:
8080
DatadogAccountIntegrationTrailBucket:
8181
Type: AWS::S3::Bucket
8282
Properties:
83-
BucketName: "automatic-account-integration-trail-bucket"
83+
BucketName:
84+
Fn::Join:
85+
- "-"
86+
- - "datadog-account-integration"
87+
- !Select
88+
- 0
89+
- !Split
90+
- "-"
91+
- !Select
92+
- 2
93+
- !Split
94+
- "/"
95+
- !Ref "AWS::StackId"
8496
DatadogAccountIntegrationTrailBucketPolicy:
8597
Type: AWS::S3::BucketPolicy
8698
Properties:
@@ -149,6 +161,7 @@ Resources:
149161
return
150162
151163
# We need to add a sleep here, to allow AWS finish provisioning of a new AWS account.
164+
print(f"Sleep for 3 minutes to allow AWS finish provisioning of a new AWS account")
152165
time.sleep(180)
153166
154167
newAccountId = event.get("detail").get("serviceEventDetails").get("createAccountStatus").get("accountId")
@@ -209,7 +222,9 @@ Resources:
209222
)
210223
211224
stack_id = response["StackId"]
212-
225+
226+
print(f"Wait for Datadog Integration for account {newAccountId} to be created")
227+
213228
while True:
214229
response = client.describe_stacks(StackName=stack_id)
215230
if response["Stacks"][0]["StackStatus"] == "CREATE_IN_PROGRESS":
@@ -221,7 +236,6 @@ Resources:
221236
break
222237
223238
print(f"Datadog Integration for account {newAccountId} failed to create")
224-
print(response)
225239
RuntimeError(f"Datadog Integration for account {newAccountId} failed to create")
226240
Environment:
227241
Variables:

0 commit comments

Comments
 (0)