Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): elastic search without slow logs FP #4317

Merged
merged 1 commit into from
Sep 29, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@ package Cx

import data.generic.common as common_lib

slowLogs := ["INDEX_SLOW_LOGS", "SEARCH_SLOW_LOGS"]

CxPolicy[result] {
resource := input.document[i].Resources[name]
resource.Type == "AWS::Elasticsearch::Domain"
logs := resource.Properties.LogPublishingOptions[log]
not contains(["INDEX_SLOW_LOGS", "SEARCH_SLOW_LOGS"], log)
common_lib.valid_key(resource.Properties, "LogPublishingOptions")
logs := [logName | contains(slowLogs, logName); log := resource.Properties.LogPublishingOptions[logName]]
count(logs) == 0

result := {
"documentId": input.document[i].id,
"searchKey": sprintf("Resources.%s.Properties.LogPublishingOptions.%s", [name, log]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is slow logs", [name, log]),
"keyActualValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is not not slow logs", [name, log]),
"searchKey": sprintf("Resources.%s.Properties.LogPublishingOptions", [name]),
"issueType": "MissingAttribute",
"keyExpectedValue": sprintf("Resources.%s.Properties.LogPublishingOptions declares slow logs", [name]),
"keyActualValue": sprintf("Resources.%s.Properties.LogPublishingOptions does not declares slow logs", [name]),
"searchLine": common_lib.build_search_line(["Resource", name, "Properties", "LogPublishingOptions"], []),
}
}

CxPolicy[result] {
resource := input.document[i].Resources[name]
resource.Type == "AWS::Elasticsearch::Domain"
logs := resource.Properties.LogPublishingOptions[log]
contains(["INDEX_SLOW_LOGS", "SEARCH_SLOW_LOGS"], log)
logs := resource.Properties.LogPublishingOptions[logName]
logName == slowLogs[j]
logs.Enabled == "false"

result := {
"documentId": input.document[i].id,
"searchKey": sprintf("Resources.%s.Properties.LogPublishingOptions.%s.Enabled", [name, log]),
"searchKey": sprintf("Resources.%s.Properties.LogPublishingOptions.%s.Enabled", [name, logName]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is a slow log and is enabled", [name, logs]),
"keyActualValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is a slow log but isn't enabled", [name, logs]),
"keyExpectedValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is a slow log and is enabled", [name, logName]),
"keyActualValue": sprintf("Resources.%s.Properties.LogPublishingOptions.%s is a slow log but isn't enabled", [name, logName]),
"searchLine": common_lib.build_search_line(["Resource", name, "Properties", "LogPublishingOptions", logName, "Enabled"], []),
}
}

Expand All @@ -46,6 +51,7 @@ CxPolicy[result] {
"issueType": "MissingAttribute",
"keyExpectedValue": sprintf("Resources.%s.Properties.LogPublishingOptions is defined and not null", [name]),
"keyActualValue": sprintf("Resources.%s.Properties.LogPublishingOptions is undefined or null", [name]),
"searchLine": common_lib.build_search_line(["Resource", name, "Properties"], []),
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,40 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Description: ElasticsearchDomain resource
Parameters:
DomainName:
Description: User defined Elasticsearch Domain name
Type: String
ElasticsearchVersion:
Description: User defined Elasticsearch Version
Type: String
InstanceType:
Type: String
AvailabilityZone:
Type: String
CidrBlock:
Type: String
GroupDescription:
Type: String
SGName:
Type: String
Resources:
ElasticsearchDomain:
Type: 'AWS::Elasticsearch::Domain'
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Ref: DomainName
ElasticsearchVersion:
Ref: ElasticsearchVersion
ElasticsearchClusterConfig:
InstanceCount: '1'
InstanceCount: "1"
InstanceType:
Ref: InstanceType
EBSOptions:
EBSEnabled: 'true'
EBSEnabled: "true"
Iops: 0
VolumeSize: 10
VolumeType: standard
SnapshotOptions:
AutomatedSnapshotStartHour: '0'
AutomatedSnapshotStartHour: "0"
AccessPolicies:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Deny
Principal:
AWS: '*'
Action: 'es:*'
Resource: '*'
AWS: "*"
Action: "es:*"
Resource: "*"
LogPublishingOptions:
SEARCH_SLOW_LOGS:
CloudWatchLogsLogGroupArn: >-
arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/es-slow-logs
Enabled: 'true'
Enabled: "true"
INDEX_SLOW_LOGS:
CloudWatchLogsLogGroupArn: >-
arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/es-index-slow-logs
Enabled: 'true'
Enabled: "true"
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
rest.action.multi.allow_explicit_index: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,6 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "ElasticsearchDomain resource",
"Parameters": {
"GroupDescription": {
"Type": "String"
},
"SGName": {
"Type": "String"
},
"DomainName": {
"Description": "User defined Elasticsearch Domain name",
"Type": "String"
},
"ElasticsearchVersion": {
"Description": "User defined Elasticsearch Version",
"Type": "String"
},
"InstanceType": {
"Type": "String"
},
"AvailabilityZone": {
"Type": "String"
},
"CidrBlock": {
"Type": "String"
}
},
"Resources": {
"ElasticsearchDomain": {
"Type": "AWS::Elasticsearch::Domain",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Resources:
ProductionElasticsearch:
Type: AWS::Elasticsearch::Domain
Properties:
EBSOptions:
EBSEnabled: true
VolumeSize: 70
VolumeType: gp2
ElasticsearchClusterConfig:
DedicatedMasterCount: 3
DedicatedMasterEnabled: true
DedicatedMasterType: omitted
InstanceCount: 3
InstanceType: omitted
ZoneAwarenessConfig:
AvailabilityZoneCount: 3
ZoneAwarenessEnabled: true
ElasticsearchVersion: omitted
LogPublishingOptions:
"INDEX_SLOW_LOGS":
CloudWatchLogsLogGroupArn: !GetAtt ProductionElasticsearchIndexSlowLogs.Arn
Enabled: true
"SEARCH_SLOW_LOGS":
CloudWatchLogsLogGroupArn: !GetAtt ProductionElasticsearchSearchSlowLogs.Arn
Enabled: true
"ES_APPLICATION_LOGS":
CloudWatchLogsLogGroupArn: !GetAtt ProductionElasticsearchApplicationLogs.Arn
Enabled: true
Original file line number Diff line number Diff line change
@@ -1,57 +1,40 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Description: ElasticsearchDomain resource
Parameters:
DomainName:
Description: User defined Elasticsearch Domain name
Type: String
ElasticsearchVersion:
Description: User defined Elasticsearch Version
Type: String
InstanceType:
Type: String
AvailabilityZone:
Type: String
CidrBlock:
Type: String
GroupDescription:
Type: String
SGName:
Type: String
Resources:
ElasticsearchDomain:
Type: 'AWS::Elasticsearch::Domain'
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Ref: DomainName
ElasticsearchVersion:
Ref: ElasticsearchVersion
ElasticsearchClusterConfig:
InstanceCount: '1'
InstanceCount: "1"
InstanceType:
Ref: InstanceType
EBSOptions:
EBSEnabled: 'true'
EBSEnabled: "true"
Iops: 0
VolumeSize: 10
VolumeType: standard
SnapshotOptions:
AutomatedSnapshotStartHour: '0'
AutomatedSnapshotStartHour: "0"
AccessPolicies:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Deny
Principal:
AWS: '*'
Action: 'es:*'
Resource: '*'
AWS: "*"
Action: "es:*"
Resource: "*"
LogPublishingOptions:
SEARCH_SLOW_LOGS:
CloudWatchLogsLogGroupArn: >-
arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/es-slow-logs
Enabled: 'false'
Enabled: "false"
INDEX_SLOW_LOGS:
CloudWatchLogsLogGroupArn: >-
arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/es-index-slow-logs
Enabled: 'true'
Enabled: "true"
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
rest.action.multi.allow_explicit_index: "true"
Original file line number Diff line number Diff line change
@@ -1,53 +1,36 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Description: ElasticsearchDomain resource
Parameters:
DomainName:
Description: User defined Elasticsearch Domain name
Type: String
ElasticsearchVersion:
Description: User defined Elasticsearch Version
Type: String
InstanceType:
Type: String
AvailabilityZone:
Type: String
CidrBlock:
Type: String
GroupDescription:
Type: String
SGName:
Type: String
Resources:
ElasticsearchDomain:
Type: 'AWS::Elasticsearch::Domain'
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Ref: DomainName
ElasticsearchVersion:
Ref: ElasticsearchVersion
ElasticsearchClusterConfig:
InstanceCount: '1'
InstanceCount: "1"
InstanceType:
Ref: InstanceType
EBSOptions:
EBSEnabled: 'true'
EBSEnabled: "true"
Iops: 0
VolumeSize: 10
VolumeType: standard
SnapshotOptions:
AutomatedSnapshotStartHour: '0'
AutomatedSnapshotStartHour: "0"
AccessPolicies:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Deny
Principal:
AWS: '*'
Action: 'es:*'
Resource: '*'
AWS: "*"
Action: "es:*"
Resource: "*"
LogPublishingOptions:
ES_APPLICATION_LOGS:
CloudWatchLogsLogGroupArn: >-
arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/es-index-slow-logs
Enabled: 'true'
Enabled: "true"
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
rest.action.multi.allow_explicit_index: "true"
Original file line number Diff line number Diff line change
@@ -1,48 +1,31 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Description: ElasticsearchDomain resource
Parameters:
DomainName:
Description: User defined Elasticsearch Domain name
Type: String
ElasticsearchVersion:
Description: User defined Elasticsearch Version
Type: String
InstanceType:
Type: String
AvailabilityZone:
Type: String
CidrBlock:
Type: String
GroupDescription:
Type: String
SGName:
Type: String
Resources:
ElasticsearchDomain:
Type: 'AWS::Elasticsearch::Domain'
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Ref: DomainName
ElasticsearchVersion:
Ref: ElasticsearchVersion
ElasticsearchClusterConfig:
InstanceCount: '1'
InstanceCount: "1"
InstanceType:
Ref: InstanceType
EBSOptions:
EBSEnabled: 'true'
EBSEnabled: "true"
Iops: 0
VolumeSize: 10
VolumeType: standard
SnapshotOptions:
AutomatedSnapshotStartHour: '0'
AutomatedSnapshotStartHour: "0"
AccessPolicies:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Deny
Principal:
AWS: '*'
Action: 'es:*'
Resource: '*'
AWS: "*"
Action: "es:*"
Resource: "*"
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
rest.action.multi.allow_explicit_index: "true"
Loading