Skip to content

Commit 4408b45

Browse files
authored
Merge pull request #273 from DataDog/tian.chu/forwarder-us-gov
Ensure the forwarder can be installed to GovCloud
2 parents e474b3c + 39ebeba commit 4408b45

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

aws/logs_monitoring/template.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Parameters:
1313
Description: The Datadog API key, which can be found from the APIs page (/account/settings#api). It will be stored in AWS Secrets Manager securely. If DdApiKeySecretArn is also set, this value will not be used. This value must still be set, however.
1414
DdApiKeySecretArn:
1515
Type: String
16-
AllowedPattern: "arn:aws:secretsmanager:.*"
16+
AllowedPattern: "arn:.*:secretsmanager:.*"
1717
Default: "arn:aws:secretsmanager:DEFAULT"
1818
Description: The ARN of the secret storing the Datadog API key, if you already have it stored in Secrets Manager. You still need to set a dummy value for "DdApiKey" to satisfy the requirement, though that value won't be used.
1919
DdSite:
@@ -161,6 +161,10 @@ Parameters:
161161
Default: ""
162162
Description: ARN for the Permissions Boundary Policy
163163
Conditions:
164+
IsAWSChina:
165+
Fn::Equals:
166+
- Ref: AWS::Partition
167+
- "aws-cn"
164168
CreateDdApiKeySecret:
165169
Fn::Equals:
166170
- Ref: DdApiKeySecretArn
@@ -412,7 +416,7 @@ Resources:
412416
- Effect: Allow
413417
Action:
414418
- s3:GetObject
415-
Resource: "arn:aws:s3:::*"
419+
Resource: "*"
416420
- Effect: Allow
417421
Action:
418422
- secretsmanager:GetSecretValue
@@ -442,14 +446,22 @@ Resources:
442446
Properties:
443447
FunctionName: !Ref "Forwarder"
444448
Action: lambda:InvokeFunction
445-
Principal: !Sub "logs.${AWS::Region}.amazonaws.com"
449+
Principal:
450+
Fn::If:
451+
- IsAWSChina
452+
- !Sub "logs.${AWS::Region}.amazonaws.com.cn"
453+
- !Sub "logs.${AWS::Region}.amazonaws.com"
446454
SourceAccount: !Ref "AWS::AccountId"
447455
S3Permission:
448456
Type: AWS::Lambda::Permission
449457
Properties:
450458
FunctionName: !Ref "Forwarder"
451459
Action: lambda:InvokeFunction
452-
Principal: "s3.amazonaws.com"
460+
Principal:
461+
Fn::If:
462+
- IsAWSChina
463+
- "s3.amazonaws.com.cn"
464+
- "s3.amazonaws.com"
453465
SourceAccount: !Ref "AWS::AccountId"
454466
LogGroup:
455467
Type: AWS::Logs::LogGroup
@@ -467,6 +479,16 @@ Resources:
467479
Ref: DdApiKey
468480
ForwarderZipsBucket:
469481
Type: AWS::S3::Bucket
482+
Properties:
483+
BucketEncryption:
484+
ServerSideEncryptionConfiguration:
485+
- ServerSideEncryptionByDefault:
486+
SSEAlgorithm: AES256
487+
PublicAccessBlockConfiguration:
488+
BlockPublicAcls: true
489+
BlockPublicPolicy: true
490+
IgnorePublicAcls: true
491+
RestrictPublicBuckets: true
470492
ForwarderZip:
471493
Type: Custom::ForwarderZip
472494
Properties:
@@ -582,7 +604,7 @@ Resources:
582604
Resource:
583605
- Fn::Join:
584606
- ""
585-
- - "arn:aws:s3:::"
607+
- - "arn:*:s3:::"
586608
- !Select [1, !Split ["s3://", !Ref SourceZipUrl]]
587609
- Ref: AWS::NoValue
588610
Environment:

0 commit comments

Comments
 (0)