Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 24 additions & 14 deletions packages/@aws-cdk/aws-elasticsearch/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,29 @@ export class Domain extends DomainBase implements IDomain {
});
}

const logPublishing: Record<string, any> = {};

if (this.appLogGroup) {
logPublishing.ES_APPLICATION_LOGS = {
enabled: true,
cloudWatchLogsLogGroupArn: this.appLogGroup.logGroupArn,
};
}

if (this.slowSearchLogGroup) {
logPublishing.SEARCH_SLOW_LOGS = {
enabled: true,
cloudWatchLogsLogGroupArn: this.slowSearchLogGroup.logGroupArn,
};
}

if (this.slowIndexLogGroup) {
logPublishing.INDEX_SLOW_LOGS = {
enabled: true,
cloudWatchLogsLogGroupArn: this.slowIndexLogGroup.logGroupArn,
};
}

// Create the domain
this.domain = new CfnDomain(this, 'Resource', {
domainName: this.physicalName,
Expand Down Expand Up @@ -1451,20 +1474,7 @@ export class Domain extends DomainBase implements IDomain {
: undefined,
},
nodeToNodeEncryptionOptions: { enabled: nodeToNodeEncryptionEnabled },
logPublishingOptions: {
ES_APPLICATION_LOGS: {
enabled: this.appLogGroup != null,
cloudWatchLogsLogGroupArn: this.appLogGroup?.logGroupArn,
},
SEARCH_SLOW_LOGS: {
enabled: this.slowSearchLogGroup != null,
cloudWatchLogsLogGroupArn: this.slowSearchLogGroup?.logGroupArn,
},
INDEX_SLOW_LOGS: {
enabled: this.slowIndexLogGroup != null,
cloudWatchLogsLogGroupArn: this.slowIndexLogGroup?.logGroupArn,
},
},
logPublishingOptions: logPublishing,
cognitoOptions: {
enabled: props.cognitoKibanaAuth != null,
identityPoolId: props.cognitoKibanaAuth?.identityPoolId,
Expand Down
30 changes: 1 addition & 29 deletions packages/@aws-cdk/aws-elasticsearch/test/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,7 @@ test('minimal example renders correctly', () => {
EncryptionAtRestOptions: {
Enabled: false,
},
LogPublishingOptions: {
ES_APPLICATION_LOGS: {
Enabled: false,
},
SEARCH_SLOW_LOGS: {
Enabled: false,
},
INDEX_SLOW_LOGS: {
Enabled: false,
},
},
LogPublishingOptions: {},
NodeToNodeEncryptionOptions: {
Enabled: false,
},
Expand All @@ -75,9 +65,6 @@ describe('log groups', () => {

expect(stack).toHaveResourceLike('AWS::Elasticsearch::Domain', {
LogPublishingOptions: {
ES_APPLICATION_LOGS: {
Enabled: false,
},
SEARCH_SLOW_LOGS: {
CloudWatchLogsLogGroupArn: {
'Fn::GetAtt': [
Expand All @@ -87,9 +74,6 @@ describe('log groups', () => {
},
Enabled: true,
},
INDEX_SLOW_LOGS: {
Enabled: false,
},
},
});
});
Expand All @@ -104,12 +88,6 @@ describe('log groups', () => {

expect(stack).toHaveResourceLike('AWS::Elasticsearch::Domain', {
LogPublishingOptions: {
ES_APPLICATION_LOGS: {
Enabled: false,
},
SEARCH_SLOW_LOGS: {
Enabled: false,
},
INDEX_SLOW_LOGS: {
CloudWatchLogsLogGroupArn: {
'Fn::GetAtt': [
Expand Down Expand Up @@ -142,12 +120,6 @@ describe('log groups', () => {
},
Enabled: true,
},
SEARCH_SLOW_LOGS: {
Comment thread
iliapolo marked this conversation as resolved.
Enabled: false,
},
INDEX_SLOW_LOGS: {
Enabled: false,
},
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,7 @@
"EncryptionAtRestOptions": {
"Enabled": true
},
"LogPublishingOptions": {
"ES_APPLICATION_LOGS": {
"Enabled": false
},
"SEARCH_SLOW_LOGS": {
"Enabled": false
},
"INDEX_SLOW_LOGS": {
"Enabled": false
}
},
"LogPublishingOptions": {},
"NodeToNodeEncryptionOptions": {
"Enabled": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"Resources": {
"DomainESLogGroupPolicyCustomResourcePolicyB35C8E41": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "logs:PutResourcePolicy",
"Effect": "Allow",
"Resource": "*"
},
{
"Action": "logs:DeleteResourcePolicy",
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "DomainESLogGroupPolicyCustomResourcePolicyB35C8E41",
"Roles": [
{
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
]
}
},
"DomainESLogGroupPolicy5373A2E8": {
"Type": "Custom::CloudwatchLogResourcePolicy",
"Properties": {
Expand Down Expand Up @@ -83,11 +109,11 @@
},
"InstallLatestAwsSdk": true
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"DependsOn": [
"DomainESLogGroupPolicyCustomResourcePolicyB35C8E41"
]
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"Domain66AC69E0": {
"Type": "AWS::Elasticsearch::Domain",
Expand Down Expand Up @@ -132,9 +158,6 @@
]
},
"Enabled": true
},
"INDEX_SLOW_LOGS": {
"Enabled": false
}
},
"NodeToNodeEncryptionOptions": {
Expand Down Expand Up @@ -193,32 +216,6 @@
]
}
},
"DomainESLogGroupPolicyCustomResourcePolicyB35C8E41": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "logs:PutResourcePolicy",
"Effect": "Allow",
"Resource": "*"
},
{
"Action": "logs:DeleteResourcePolicy",
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "DomainESLogGroupPolicyCustomResourcePolicyB35C8E41",
"Roles": [
{
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
]
}
},
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
"Type": "AWS::Lambda::Function",
"Properties": {
Expand Down Expand Up @@ -276,17 +273,17 @@
}
},
"Parameters": {
"AssetParametersb64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94ArtifactHash782948FC": {
"Type":"String",
"Description":"Artifact hash for asset \"b64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94\""
},
"AssetParametersb64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94S3Bucket38F1BB8E": {
"Type": "String",
"Description": "S3 bucket for asset \"b64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94\""
},
"AssetParametersb64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94S3VersionKeyCCDC67C0": {
"Type": "String",
"Description": "S3 key for asset version \"b64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94\""
},
"AssetParametersb64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94ArtifactHash782948FC": {
"Type": "String",
"Description": "Artifact hash for asset \"b64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94\""
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"Type": "AWS::SecretsManager::Secret",
"Properties": {
"GenerateSecretString": {
"GenerateStringKey": "password",
"ExcludeCharacters": "{}'\\*[]()`",
"GenerateStringKey": "password",
"SecretStringTemplate": "{\"username\":\"admin\"}"
}
}
Expand Down Expand Up @@ -54,17 +54,7 @@
"EncryptionAtRestOptions": {
"Enabled": true
},
"LogPublishingOptions": {
"ES_APPLICATION_LOGS": {
"Enabled": false
},
"SEARCH_SLOW_LOGS": {
"Enabled": false
},
"INDEX_SLOW_LOGS": {
"Enabled": false
}
},
"LogPublishingOptions": {},
"NodeToNodeEncryptionOptions": {
"Enabled": true
}
Expand Down Expand Up @@ -294,4 +284,4 @@
"Description": "Artifact hash for asset \"b64b129569a5ac7a9abf88a18ac0b504d1fb1208872460476ed3fd435830eb94\""
}
}
}
}