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

Trusted Advisor Integration V1 #109

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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 deployment/build_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
PACKAGES_DIR="${SCRIPT_PATH}/packages/"
LIBRARY="${SCRIPT_PATH}/../hammer/library"

LAMBDAS="ami-info logs-forwarder ddb-tables-backup sg-issues-identification s3-acl-issues-identification s3-policy-issues-identification iam-keyrotation-issues-identification iam-user-inactive-keys-identification cloudtrails-issues-identification ebs-unencrypted-volume-identification ebs-public-snapshots-identification rds-public-snapshots-identification sqs-public-policy-identification s3-unencrypted-bucket-issues-identification rds-unencrypted-instance-identification ami-public-access-issues-identification api ecs-privileged-access-issues-identification ecs-logging-issues-identification ecs-external-image-source-issues-identification redshift-audit-logging-issues-identification redshift-unencrypted-cluster-identification redshift-cluster-public-access-identification elasticsearch-domain-logging-issues-identification elasticsearch-unencrypted-domain-identification elasticsearch-public-access-domain-identification"
LAMBDAS="ami-info logs-forwarder ddb-tables-backup sg-issues-identification s3-acl-issues-identification s3-policy-issues-identification iam-keyrotation-issues-identification iam-user-inactive-keys-identification cloudtrails-issues-identification ebs-unencrypted-volume-identification ebs-public-snapshots-identification rds-public-snapshots-identification sqs-public-policy-identification s3-unencrypted-bucket-issues-identification rds-unencrypted-instance-identification ami-public-access-issues-identification api ecs-privileged-access-issues-identification ecs-logging-issues-identification ecs-external-image-source-issues-identification redshift-audit-logging-issues-identification redshift-unencrypted-cluster-identification redshift-cluster-public-access-identification elasticsearch-domain-logging-issues-identification elasticsearch-unencrypted-domain-identification elasticsearch-public-access-domain-identification trusted-advisor-checks-identification"

pushd "${SCRIPT_PATH}" > /dev/null
pushd ../hammer/identification/lambdas > /dev/null
Expand Down
64 changes: 62 additions & 2 deletions deployment/cf-templates/ddb.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@
},
"TableName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "ecs-privileged-access" ] ]}
}
},
},
"DynamoDBECSLogging": {
"Type": "AWS::DynamoDB::Table",
"DeletionPolicy": "Retain",
Expand Down Expand Up @@ -734,7 +734,7 @@
},
"TableName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "es-unencrypted-domain" ] ]}
}
},
},
"DynamoDBESPublicAccessRequests": {
"Type": "AWS::DynamoDB::Table",
"DependsOn": ["DynamoDBCredentials"],
Expand Down Expand Up @@ -765,6 +765,66 @@
},
"TableName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "es-public-access-domain" ] ]}
}
},
"DynamoDBTrustedAdvisorEC2LowUtil": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"AttributeDefinitions": [
{
"AttributeName": "account_id",
"AttributeType": "S"
},
{
"AttributeName": "issue_id",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "account_id",
"KeyType": "HASH"
},
{
"AttributeName": "issue_id",
"KeyType": "RANGE"
}
],
"BillingMode": "PAY_PER_REQUEST",
"SSESpecification": {
"SSEEnabled": true
},
"TableName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "trusted-advisor-cost-optimizing-low-utilization-ec2-instances" ] ]}
}
},
"DynamoDBTrustedAdvisorFaultToleranceEBS": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"AttributeDefinitions": [
{
"AttributeName": "account_id",
"AttributeType": "S"
},
{
"AttributeName": "issue_id",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "account_id",
"KeyType": "HASH"
},
{
"AttributeName": "issue_id",
"KeyType": "RANGE"
}
],
"BillingMode": "PAY_PER_REQUEST",
"SSESpecification": {
"SSEEnabled": true
},
"TableName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "trusted-advisor-fault-tolerance-ebs-snapshots" ] ]}
}
}
}
}
8 changes: 8 additions & 0 deletions deployment/cf-templates/identification-crossaccount-role.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@
"es:ListTags"
],
"Resource": "*"
},
{
"Sid": "HammerSupportPolicy",
"Effect": "Allow",
"Action": [
"support:*"
],
"Resource": "*"
}
]
}
Expand Down
8 changes: 8 additions & 0 deletions deployment/cf-templates/identification-role.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@
"Resource": {
"Fn::Join": ["", ["arn:aws:iam::*:role/", { "Ref": "ResourcesPrefix" }, {"Ref": "IdentificationCrossAccountIAMRole"}]]
}
},
{
"Sid": "HammerSupportPolicy",
"Effect": "Allow",
"Action": [
"support:*"
],
"Resource": "*"
}
]
}
Expand Down
67 changes: 62 additions & 5 deletions deployment/cf-templates/identification.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"SourceIdentificationECSExternalImageSource",
"SourceIdentificationElasticSearchLogging",
"SourceIdentificationElasticSearchEncryption",
"SourceIdentificationElasticSearchPublicAccess"
"SourceIdentificationElasticSearchPublicAccess",
"SourceIdentificationTAChecks"
]
},
{
Expand Down Expand Up @@ -127,7 +128,10 @@
"dafault": "Relative path to Unencrypted Elasticsearch domain sources"
},
"SourceIdentificationElasticSearchPublicAccess":{
"dafault": "Relative path to Unencrypted Elasticsearch domain public access sources"
"dafault": "Relative path to Unencrypted Elasticsearch domain public access sources"
},
"SourceIdentificationTAChecks": {
"default": "Relative path to trusted advisor check sources"
}
}
}
Expand Down Expand Up @@ -247,7 +251,7 @@
},
"SourceIdentificationECSExternalImageSource": {
"Type": "String",
"Default": "ecs-image-source-issues-identification.zip"
"Default": "ecs-external-image-source-issues-identification.zip"
},
"SourceIdentificationElasticSearchLogging": {
"Type": "String",
Expand All @@ -260,7 +264,11 @@
"SourceIdentificationElasticSearchPublicAccess": {
"Type": "String",
"Default": "elasticsearch-public-access-domain-identification.zip"
}
},
"SourceIdentificationTAChecks": {
"Type": "String",
"Default": "trusted-advisor-checks-identification.zip"
}
},
"Conditions": {
"LambdaSubnetsEmpty": {
Expand Down Expand Up @@ -473,6 +481,12 @@
"SNSTopicNameESPublicAccess": {
"value": "describe-es-public-access-lambda"
},
"SNSDisplayNameTAChecks": {
"value": "describe-ta-checks-sns"
},
"SNSTopicNameTAChecks": {
"value": "describe-ta-checks-lambda"
},
"LogsForwarderLambdaFunctionName": {
"value": "logs-forwarder"
},
Expand Down Expand Up @@ -544,6 +558,9 @@
},
"ESPublicAccessLambdaFunctionName": {
"value": "elasticsearch-public-access"
},
"TAChecksLambdaFunctionName": {
"value": "ta-checks"
}
}
},
Expand Down Expand Up @@ -1592,7 +1609,47 @@
{ "Fn::FindInMap": ["NamingStandards", "SNSDisplayNameESPublicAccess", "value"] } ]
]},
"SNSTopicName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" },
{ "Fn::FindInMap": ["NamingStandards", "SNSTopicNameESPublicAccess", "value"] } ]
{ "Fn::FindInMap": ["NamingStandards", "SNSTopicNameESPublicAccess", "value"] } ]
]},
"SNSIdentificationErrors": {"Ref": "SNSIdentificationErrors"}
}
}
},
"StackEvaluateTAChecks": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": {"Ref": "NestedStackTemplate"},
"Parameters": {
"SourceS3Bucket": { "Ref": "SourceS3Bucket" },
"IdentificationIAMRole": {"Fn::Join" : ["", [ "arn:aws:iam::",
{ "Ref": "AWS::AccountId" },
":role/",
{ "Ref": "ResourcesPrefix" },
{ "Ref": "IdentificationIAMRole" }
] ]},
"IdentificationCheckRateExpression": {"Fn::Join": ["", [ "cron(", "40 ", { "Ref": "IdentificationCheckRateExpression" }, ")" ] ]},
"LambdaSubnets": {"Ref": "LambdaSubnets"},
"LambdaSecurityGroups": {"Ref": "LambdaSecurityGroups"},
"IdentificationLambdaSource": { "Ref": "SourceIdentificationTAChecks" },
"InitiateLambdaDescription": "Lambda function for initiate trusted advisor's checks.",
"EvaluateLambdaDescription": "Lambda function to describe trusted advisor's checks.",
"InitiateLambdaName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "initiate-",
{ "Fn::FindInMap": ["NamingStandards", "TAChecksLambdaFunctionName", "value"] } ]
]},
"EvaluateLambdaName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" }, "describe-",
{ "Fn::FindInMap": ["NamingStandards", "TAChecksLambdaFunctionName", "value"] } ]
]},
"InitiateLambdaHandler": "initiate_to_desc_ta_checks.lambda_handler",
"EvaluateLambdaHandler": "describe_ta_checks.lambda_handler",
"EvaluateLambdaMemorySize": 256,
"LambdaLogsForwarderArn": { "Fn::GetAtt": ["LambdaLogsForwarder", "Arn"] },
"EventRuleDescription": "Hammer ScheduledRule to initiate Trusted Advisor Checks",
"EventRuleName": {"Fn::Join" : ["", [{ "Ref": "ResourcesPrefix" }, "InitiateEvaluationTAChecks"] ] },
"SNSDisplayName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" },
{ "Fn::FindInMap": ["NamingStandards", "SNSDisplayNameTAChecks", "value"] } ]
]},
"SNSTopicName": {"Fn::Join" : ["", [ { "Ref": "ResourcesPrefix" },
{ "Fn::FindInMap": ["NamingStandards", "SNSTopicNameTAChecks", "value"] } ]
]},
"SNSIdentificationErrors": {"Ref": "SNSIdentificationErrors"}
}
Expand Down
53 changes: 49 additions & 4 deletions deployment/configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"text_field_character_limit": 32767
},
"slack": {
"enabled": true,
"enabled": false,
"notify_default_owner": true,
"channels": {
"#hammer-slave1": ["ERROR|WARNING|ALARM|Task timed out after|Access denied"]
Expand Down Expand Up @@ -168,7 +168,7 @@
"ddb.table_name": "hammer-redshift-logging",
"topic_name": "hammer-describe-redshift-logging-lambda",
"reporting": true
},
},
"redshift_public_access": {
"enabled": true,
"ddb.table_name": "hammer-redshift-public-access",
Expand Down Expand Up @@ -203,7 +203,7 @@
"ddb.table_name": "hammer-ecs-external-image-source",
"reporting": true,
"safe_image_sources": ["amazonaws", "artifactory"]
},
},
"es_domain_logging": {
"enabled": true,
"ddb.table_name": "hammer-es-domain-logging",
Expand All @@ -217,13 +217,58 @@
"ddb.table_name": "hammer-es-unencrypted-domain",
"topic_name": "hammer-describe-es-encryption-lambda",
"reporting": true
},
},
"es_public_access_domain": {
"enabled": true,
"ddb.table_name": "hammer-es-public-access-domain",
"topic_name": "hammer-describe-es-public-access-lambda",
"reporting": true,
"remediation": false,
"remediation_retention_period": 21
},
"trusted_advisor_recommendations": {
"enabled": true,
"refreshtimeoutinminutes": 8,
"checks": [
{
"category": "cost_optimizing",
"checkname": "Low Utilization Amazon EC2 Instances",
"name": "trusted_advisor_recommendations_low_ec2_utilization",
"accounts": [
"123456789012",
"098765432109"
],
"filters": [
{
"attribute": "Estimated Monthly Savings",
"operator": "gt",
"value": "500"
},
{
"attribute": "Number of Days Low Utilization",
"operator": "eq",
"value": "14"
}
],
"ddb.table_name": "trusted-advisor-cost-optimizing-low-utilization-ec2-instances"
},
{
"category": "fault_tolerance",
"checkname": "Amazon EBS Snapshots",
"name": "trusted_advisor_recommendations_ebs_snapshots",
"accounts": [
"123456789012",
"098765432109"
],
"filters": [
{
"attribute": "Status",
"operator": "eq",
"value": "Red"
}
],
"ddb.table_name": "trusted-advisor-fault-tolerance-ebs-snapshots"
}
]
}
}
Loading