Git Product home page Git Product logo

aws-config-engine-for-compliance-as-code's Introduction

NOTICE

This project is not maintained any more: please reachout to [email protected] for any questions. Please checkout branch Version2 for latest features which support a more complicated use cases and this version will remain as a minimum vialbe product

Engine for Compliance-as-code

This package is a collaborative project to deploy and operate Config Rules at scale in an multi-account environment.

Objectives of the package

  1. Deploy automatically and operate configurable sets of AWS Config Rules in a multi-account environment.
  2. Provide insights and records on the compliance status of all AWS Accounts and resources.
  3. Provide an initial set of recommended AWS Config Rules.

Key Features

  1. Analyze current situation and trends from the compliance account as all data are pushed in a Datalake.
  2. Use your favorite analytics tool (Amazon QuickSight, Tableau, Splunk, etc.) as the data is formatted to be directly consumable.
  3. Classify your AWS accounts to deploy only relevant Config Rules depending of your classification (e.g. application type, resilience, stage, sensitvity, etc.).
  4. Ensure that the deployed Rules in each Account are always up-to-date.
  5. Store all historical data of all the changes by storing the compliance record in a centralized and durable Amazon S3 bucket.
  6. Deploy easily in 100s of accounts: by having a 1-step process for any new application account via AWS CloudFormation.
  7. Protect the code base: by centralizing the code base of all the compliance-as-code rules in a dedicated "Compliance Account".
  8. Make use of the AWS Config Rules Dashboard to display the details of compliance status of your AWS resources by setting up Config Aggregator.

Getting Started

In a single AWS Region (in a single or multi-account environment)

You can follow the steps below to install the Compliance Engine.

Requirements

  1. Define an AWS Account to be the central location for the engine (Compliance Account).
  2. Define the AWS Accounts to be verified by the engine (Application Accounts). Note: the Compliance Account can be verified to.

In the Compliance Account

  1. Deploy compliance-account-initial-setup.yaml in your centralized account. Change the MainRegion parameter to match the region where you are deploying this template, if required.
  2. Zip the 2 directories "rules/" and "rulesets-built/" into "ruleset.zip", including the directories themselves.
  3. Copy the "ruleset.zip" in the source bucket (i.e. by default "compliance-engine-codebuild-source-account_id-region_name")
  4. Go to CodePipeline, then locate the pipeline named "Compliance-Engine-Pipeline". Wait that it auto-triggers (it might show "Failed" when you check for the first time).

In the Application Accounts

  1. Deploy application-account-initial-setup.yaml.

Verify the deployment works

  1. Verify in the Compliance Account that the CodePipeline pipeline named "Compliance-Engine-Pipeline" is executed succesfully
  2. Verify in the Application Account that the Config Rules are deployed.

In multiple AWS Region (in a single or multi-account environment)

  1. Follow the "Getting Started" in a single AWS Region (above)
  2. Follow the "Add a new Region" in the User Guide (below)

FAQ

What are the benefits to use of this Compliance engine?

This project assist you to manage, deploy and operate Config Rules in large AWS environment. It completely automate those tasks via a preconfigured pipeline. Additionally, it provides recommended Config Rules to be deployed as Security Baseline, mapped to the CIS Benchmark and PCI (named RuleSets).

What is a RuleSet?

A RuleSet is a collection of Rules. For any AWS accounts, you can decide which RuleSet you want to deploy. For example, you might have a RuleSet for highly confidential accounts, or for high-available accounts or for particular standards (e.g. CIS, PCI or NIST).

Can I add new Rules or new RuleSets?

Yes, we describe in the User Guide how to add new rules and new rulesets.

What are the limits to expect from the Engine?

We expect the engine to work for 100s of accounts, we are yet to hit the limit. The limit for the number of rules per account is about 65 rules, due to CloudFormation template size limits.

Does the engine support multi-region?

Yes, the engine is able to deploy different sets of rules between regions and accounts. By default, it deploys 2 different baselines of rules (avoid to deploy multiple rules with global scope only once, i.e. rules on AWS IAM).

Does the engine use AWS Organizations?

No, for simplicity of the deployment and due to the multiple dimensions of each account we decided not to use AWS Organizations.

I am already using AWS Config today. Can I still use the Engine?

Yes, the engine is compatible with an existing setup.

Overall Design

High Level Design

The engine for compliance-as-code design has the following key elements:

  • Application account(s): AWS account(s) which has a set of requirements in terms of compliance controls. The engine verifies the compliance controls implemented in this account.
  • Compliance account: the AWS account which contains the code representing the compliance requirements. It should be a restricted environment. Notification, Historical data storage and reporting are driven from this account.

config-engine-high-level-design

Low Level Design

config-engine-low-level-design

RuleSets

The set of Rules deployed in each Aplication Account depends on:

  • initial deployment of compliance-account-initial-setup.yaml: the parameter "DefaultRuleSet" in the CloudFormation template represents the default RuleSet to be deployed in any Application Accounts (main Region), not registered in account_list.json. For other regions (not the main Region), the parameter "DefaultRuleSetOtherRegions" in the CloudFormation template represents the default RuleSet to be deployed.
  • account_list.json (optional): this file includes the metadata of the accounts and their classifications (via tags)
  • rules/RULE_NAME/parameters.json: those files are included in each rule folder. Those rule metadata are matched with account metadata to deploy the proper Ruleset in each account.

Deployment Flow

  1. When a new Application Account is added via the application-account-initial-setup.yaml, one rule is installed (by default named COMPLIANCE_RULESET_LATEST_INSTALLED)
  2. This rule verifies if the correct Config rules are installed.
  3. If not, the rule create an empty account_id.json file to register, and it triggers the CodePipeline in the Compliance Account.
  4. The pipeline looks at all accounts installed (all json file) and matches with their metadata stored in account_list.json.
  5. If the account has no metadata (ie. not registered), the pipeline create a default template with the default ruleset (by default: baseline).
  6. The pipeline then deploy the account-specific AWS Config Rules via CloudFormation in all AWS accounts (registered or not in account_list.json).
  7. The COMPLIANCE_RULESET_LATEST_INSTALLED rule is trigger every 24h (configurable) to verify that the installed ruleset is still current.

User Guide

Add a new Application Account in scope in 1 step

In Application Account, deploy (in the same region) the CloudFormation: application-account-initial-setup.yaml.

This Cloudformation does the following:

  • enable and centralize Config
  • deploy an IAM role to allow the Compliance Engine to interact
  • deploy 1 Config Rule, used for verifying that the proper Rules are deployed. If non-compliant, it will trigger automatically the deployment of an update.

After few minutes, all the Config Rules defined as "baseline" (configurable) will be deployed in this new Application Account.

Add a whitelisted/exception resource from a particular Rule

Certain resources may have a business need to not follow a particular rule. You can whitelist a resouce from being NON_COMPLIANT in the datalake, where you can query the compliance data. The resource will be then be noted as COMPLIANT, and the flag "WhitelistedComplianceType" will be set to "True" for traceability.

To add a resource in the whitelist:

  1. Update the file ./rulesets-build/compliance-whitelist.json (for model, there are dummy examples).
  2. Ensure that the location of the whitelist is correct in the code ./rulesets-build/etl_evaluations.py
  3. Ensure the WhitelistLocation parameter in compliance-account-initial-setup.yaml is correct

Note: the resource will still be shown non-compliant in the AWS console of Config Rules.

Note 2: certain Rules might have a whitelist/exception in the parameters.json, but only for custom Config rules.

Add a new Region

  1. In the Compliance Account, update compliance-account-initial-setup.yaml adding the region in the OtherActiveRegions parameter. You can add several regions.
  2. In the Compliance Account, deploy (in the additional region) the CloudFormation: compliance-account-initial-setup.yaml. No change is required in your original parameters.
  3. Run the pipeline in the main region. It deploys the supporting infrastructure (including buckets and lambdas) in the other region of your Compliance Account.
  4. In the Application Account, deploy (in the additional region) the CloudFormation: application-account-initial-setup.yaml. No change is required in your original parameters.

Deploy Rules differently depending of AWS Accounts (in a single Region scenario)

This is an advanced scenario, where you want to deploy more than the default baseline. In this scenario, you can chose precisely which rule get deployed in which account(s) in the main Region.

Add an Account list

  1. Create an account_list.json, following the format:
{
	"AllAccounts": [{
		"Accountname": "Test Account 1",
		"AccountID": "123456789012",
		"OwnerEmail": ["[email protected]"],
		"RootEmail" : "[email protected]",
        "Tags": ["baseline", "confidentiality:high"]
	}]
}
  1. Update the compliance-account-initial-setup with the account list location

Create the link between Account and Rules

The engine matches the Tags in the account_list.json with the Tags in the parameters.json of the Rules. When a match is detected, the Rule is deployed in the target account.

Deploy rules differently depending of AWS Accounts and Regions (in a multiple Regions scenario)

This is an advanced scenario, where you want to deploy more than 2 different regional baselines. In this scenario, you can chose precisely which rule get deployed in which account(s) and in which region(s).

Add an Account list

  1. Create an account_list.json, following the format (notice the "Region" key):
{
	"AllAccounts": [{
		"Accountname": "Test Account 1",
		"AccountID": "123456789012",
		"OwnerEmail": ["[email protected]"],
		"RootEmail" : "[email protected]",
        "Region": "us-west-1",
        "Tags": ["baseline", "confidentiality:high"]
	}, {
		"Accountname": "Test Account 1",
		"AccountID": "123456789012",
		"OwnerEmail": ["[email protected]"],
		"RootEmail" : "[email protected]",
        "Region": "ap-southeast-1",
        "Tags": ["otherregionsbaseline", "confidentiality:high"]
	}]
}
  1. Update the compliance-account-initial-setup with the account list location

Create the link between Account and Rules

The engine matches the Tags in the account_list.json with the Tags in the parameters.json of the Rules. When a match is detected, the Rule is deployed in the target region of the account.

Add a new Config Rule in a RuleSet

Add a custom Rule to a RuleSet

  1. Create the rule with the RDK (https://github.com/awslabs/aws-config-rdk)

  2. Copy the entire RDK rule folder into the ./rules/ (including the 2 python files (code and test) and the parameters.json)

  3. Use the RDK feature for "RuleSets" to add the rules to the appropriate RuleSet. By default, no RuleSet is configured. If you don't use the account_list.json, tag the rule with the value of the parameter "DefaultRuleSet" (the one in the CloudFormation template) to deploy in the main region and/or tag the rule with the value of the parameter "DefaultRuleSetOtherRegions" to deploy in the other region(s) (not main).

  4. Add it into the "ruleset.zip" (see initial deployment section for details)

  5. Run the CodePipeline pipeline named "Compliance-Engine-Pipeline"

Add a managed Rule to a RuleSet

  1. Follow the RDK instructions to add a Managed Rules in particular RuleSets.
  2. Add it into the "ruleset.zip" (see initial deployment section for details)
  3. Run the CodePipeline pipeline named "Compliance-Engine-Pipeline"

Visualize all the Compliance data using the Compliance-as-code Datalake

Set up the Compliance Account

Execute the saved Athena Queries that you can find in Athena > Saved Queries

  • 1-Database For ComplianceAsCode
  • 2-Table For ComplianceAsCode
  • 3-Table For Config in ComplianceAsCode
  • 4-Table For AccountList (if account_list.json is configured)

Set up Amazon QuickSight

See official documentation to import an Athena query in QuickSight: https://docs.aws.amazon.com/quicksight/latest/user/create-a-data-set-athena.html

  • Make sure you add the Athena Results bucket and the original bucket in QuickSight settings.
  • We recommend to use SPICE for best performance.
  • Remember to add a scheduler to refresh the SPICE Data Set(s) daily

Prepare the data sets

Change the data type for the enginerecordedtime, resultrecordedtime & configruleinvokedtime from String to Data: yyyy-MM-dd HH:mm:ss

You need to create manually Calculated Fields. Here's some useful Formula examples:

DataAge: dateDiff({enginerecordedtime},now())

Confidentiality: ifelse(isNull({accountid[accountlist]}),"NOT REGISTERED",toUpper(split({tag2},":",2)))

WeightedConfidentiality: ifelse({Confidentiality} = "HIGH",3,{Confidentiality} = "MEDIUM",2,{Confidentiality} = "LOW",1,0)

WeightedRuleCriticity: ifelse({rulecriticity} = "1_CRITICAL",4,{rulecriticity} = "2_HIGH",3,{rulecriticity} = "3_MEDIUM",2,{rulecriticity} = "4_LOW",1,0)

ClassCriti: {WeightedClassification} * {WeightedRuleCriticity}

KinesisProcessingError: ifelse(isNull({configrulearn}),"ERROR", "OK")

Create Compliance dashboard on Amazon QuickSight

Create Visuals

The following are visual you can leverage. The format is:

Name of the Visual : type of QuickSight Visual - configuration of the Visual - filter on the Visual.

Operational Metrics

60-day trend on Number of AWS Accounts by Classification : Line Chart - X Axis: DataAge; Value: AccountID (Count Distinct); Color: AccountClassification - Filter: DataAge <= 60

Accounts with Critical Non-Compliant Rules : Horizontal Stack Bar Chart - Y Axis: AccountID; Value: RuleName (Count Distinct) - Filter: DataAge <= 1 & ClassCriti = [12,16] & ComplianceType = "NON_COMPLIANT"

60-day trend on Non-compliant Rule by ClassCriti : Line Chart - X Axis: DataAge; Value: AccountID (Count Distinct); Color: ClassCriti - Filter: DataAge <= 60

Resources in all Accounts : Horizontal Stack Bar Chart - Y Axis: ResourceType; Value: ResourceID (Count Distinct) - Filter: DataAge <= 1

Account Distribution by Account Classification : Horizontal Stack Bar Chart - Y Axis: accountclassification; Value: AccountID (Count Distinct) - Filter: DataAge = 0

Rule Distribution by Rule Criticity : Horizontal Stack Bar Chart - Y Axis: rulecriticity; Value: RuleName (Count Distinct) - Filter: DataAge <= 1

Non-Compliant Resources by RuleName and by ClassCriti : Heat Map - Row: RuleName ; Columns: ClassCriti; Values ResourceID (Count Distinct) - Filter: DataAge <= 1 & ComplianceType = "NON_COMPLIANT"

Trend of Non-Compliant Resources by Account Classification : Line Chart - X Axis: RecordedInDDBTimestamp; Value: ResourceID (Count Distinct); Color: accountclassification - Filter: ComplianceType = "NON_COMPLIANT"

List of Rules and Non-Compliant Resources: Table - Group by: rulename, resourceid; Value: ClassCriti (Max), AccountID (Count Distinct) - Filter: DataAge <= 1

Executive Metrics

Overall Compliance of Rules by Account Classification: Horizontal stacked 100% bar chart - Y axis: AccountClassification; Value: RuleArn (Count Distinct); Group/Color: ComplianceType - Filter: DataAge <= 1

Evolution of Compliance Status (last 50 days): Vertical stacked 100% bar chart - X axis: DataAge, Group/Color: ComplianceType - Filter: DataAge <= 50

Top 3 Account Non Compliant (weighted): Horizontal stacked bar chart - Y axis: AccountID , Value: DurationClassCriti (Sum), Group/Color: ClassCriti - Filter: ClassCriti >= 8

Team

  • Jonathan Rault - Idea, Design, Coding and Feedback
  • Michael Borchert - Design, Coding and Feedback

License

This project is licensed under the Apache 2.0 License

Acknowledgments

  • The RDK team makes everything so much smoother.

Related Projects

aws-config-engine-for-compliance-as-code's People

Contributors

hyandell avatar rickychau2780 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-config-engine-for-compliance-as-code's Issues

Compliance application in second region failing

Currently Have Deployed this in US-east-1 region fine to multiple accounts. I have Deployed Compliance engine and application to us-east-2. I run the Code build which runs correct. The issue is no rules are ever created in the second region. When looking at cloudformation The RDK-Config-Rule-Functions go into a rollback_failed status. Which I have no clue why.

15:28:14 UTC-0500 | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | RDK-Config-Rule-Functions | The following resource(s) failed to create: [IAMGROUPNOPOLICYFULLSTARLambdaFunction, IAMUSERNOPOLICYFULLSTARLambdaFunction, INTERNETGATEWAYAUTHORIZEDONLYLambdaFunction, IAMROLENOPOLICYFULLSTARLambdaFunction, COMPLIANCERULESETLATESTINSTALLEDLambdaFunction, EBSENCRYPTEDVOLUMESV2LambdaFunction, ROOTNOACCESSKEYLambdaFunction]. . Rollback requested by user.
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | IAMUSERNOPOLICYFULLSTARLambdaFunction | RDK-Rule-Function-IAMUSERNOPOLICYFULLSTAR already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | ROOTNOACCESSKEYLambdaFunction | RDK-Rule-Function-ROOTNOACCESSKEY already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | COMPLIANCERULESETLATESTINSTALLEDLambdaFunction | RDK-Rule-Function-COMPLIANCERULESETLATESTINSTALLED already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | IAMROLENOPOLICYFULLSTARLambdaFunction | RDK-Rule-Function-IAMROLENOPOLICYFULLSTAR already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | EBSENCRYPTEDVOLUMESV2LambdaFunction | RDK-Rule-Function-EBSENCRYPTEDVOLUMESV2 already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | IAMGROUPNOPOLICYFULLSTARLambdaFunction | RDK-Rule-Function-IAMGROUPNOPOLICYFULLSTAR already exists
  | 15:28:14 UTC-0500 | CREATE_FAILED | AWS::Lambda::Function | INTERNETGATEWAYAUTHORIZEDONLYLambdaFunction | RDK-Rule-Function-INTERNETGATEWAYAUTHORIZEDONLY already exists
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | IAMUSERNOPOLICYFULLSTARLambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | ROOTNOACCESSKEYLambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | IAMROLENOPOLICYFULLSTARLambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | COMPLIANCERULESETLATESTINSTALLEDLambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | EBSENCRYPTEDVOLUMESV2LambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | IAMGROUPNOPOLICYFULLSTARLambdaFunction |  
  | 15:28:13 UTC-0500 | CREATE_IN_PROGRESS | AWS::Lambda::Function | INTERNETGATEWAYAUTHORIZEDONLYLambdaFunction

AWS Organization Support

Is there a roadmap item to add support for AWS Organizations? I'm battling through manually enabling and configuring AWS Config under an AWS Organizations setup and was hoping I could refer to the codebase to help confirm my IAM, etc. settings

Second order errors during get_configuration in COMPLIANCE_RULESET_LATEST_INSTALLED

Part 1:
get_configuration(resource_type, resource_id, configuration_capture_time) fails when resource_type == "AWS::KMS::Key" or resource_type == "AWS::::Account".

The reason for this is GetResourceConfigHistory does not support these two resource types.

Part 2:
get_configuration(resource_type, resource_id, configuration_capture_time) also fails when resource_type == "AWS::ApiGateway::RestApi" since resource_id recorded by AWS Config service for ApiGateway::RestApi is of "arn:aws:apigateway:"+compliance_account_region+"::/restapis/"+resource_id format compared to all other resource types vs resource ids where you can pass resource_id as is.

Rules not deploying in Compliance account

When deploying the Application CFN to the main and other regions in the Compliance account, the config rules are not deploying. I am selecting "False" in the DeployAWSConfig parameters section.

Add support for scope

Many rules have a 'scope' parameter that does not seem to be supported. For example, the rule "Required_Tags" has a scope defining the 'ComplianceResourceTypes' that I would like to limit based on local policy/requirements.

Create rule template with rulestes TAG

ENV:
Python 3
installed rdk with
python3 -m pip install rdk

sample of config rule
{ "Version": "1.0", "Parameters": { "RuleName": "access_keys_rotated", "SourceRuntime": null, "CodeKey": null, "InputParameters": "{}", "OptionalParameters": "{\"maxAccessKeyAge\": \"30\"}", "SourcePeriodic": "TwentyFour_Hours", "SourceIdentifier": "ACCESS_KEYS_SOMETHING", "RuleSets": [ "tagOne" ] }, "Tags": [] }

CLI used to generate template:
rdk create-rule-template --rulesets tagOne --output-file test.json --rules-only

Output:
Generating CloudFormation template!
Traceback (most recent call last):
File "/usr/local/bin/rdk", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/rdk/cli.py", line 21, in main
return_val = my_rdk.process_command()
File "/usr/local/lib/python3.6/site-packages/rdk/rdk.py", line 341, in process_command
exit_code = method_to_call()
File "/usr/local/lib/python3.6/site-packages/rdk/rdk.py", line 1806, in create_rule_template
tags_str += "Key={},Value={} ".format(tag['Key'], tag['Value'])]]

Any one have solution to this issue, however if I have one config rule it works but not with multiple one using Rulesets tagging.

Saved Athena Queries

I am not seeing any saved Athena Queries in the "Master" or "Compliance" account. Do they get populated or deployed after the compliance engine runs the first time with rule populated in there?

Missing environment variable for deploy_rule_templates.py

Another environment variable for AWS default region needs to be added to compliance-account-initial-setup.yaml since - python ./deploy_rule_templates.py $AWS_DEFAULT_REGION $OUTPUT_BUCKET_NO_REGION $ENGINE_RULE_NAME $OTHER_ACTIVE_REGIONS in buildspec_deploytemplates.yaml takes 4 arguments.

  CodeBuildRuleDeployProject:
    Condition: IsMainRegion
    Type: AWS::CodeBuild::Project
    Properties:
      ServiceRole: !Join [ ":", ["arn:aws:iam:", !Ref 'AWS::AccountId', "role/ComplianceEngine-CodeBuildRole"]]
      Artifacts:
        Type: CODEPIPELINE
      Name: Compliance-Rule-Template-Deploy
      Description: Deploy the Config Rules CloudFormation to be deployed
      Environment:
        Type: LINUX_CONTAINER
        ComputeType: BUILD_GENERAL1_SMALL
        Image: aws/codebuild/python:3.6.5
        EnvironmentVariables:
         - Name: AWS_DEFAULT_REGION
           Value: !Ref 'AWS::Region'
         - Name: OUTPUT_BUCKET_NO_REGION
           Value: !Join [ "-", [ !Ref CodebuildDestinationS3BucketConfig, !Ref 'AWS::AccountId']]
         - Name: OTHER_ACTIVE_REGIONS
           Value: !If [ OtherActiveRegions, !Ref OtherActiveRegions, 'none']
         - Name: ENGINE_RULE_NAME
           Value: !Ref EngineComplianceRule

RDK-RULE-FUNCTION LAMBDA

The Application Account CFN is failing its update when a rule is added or modified in the compliance code pipline. The below error is shown.

The AWS Lambda function arn:aws:lambda:xxxxxxx:xxxxxxxxxxxxxxxx:function:RDK-Rule-Function-COMPLIANCERULESETLATESTINSTALLED cannot be invoked.

It appears that this section of the CFN is where the issue is. The only modifications to this CFN has been to add the Compliance account #. The Application account CFN shows this as the Lambda name in the compliance account but the Compliance account CFN does not create a Lambda function with this name.

LambdaFunctionName:
Description: Lambda name in the Compliance Account
Default: RDK-Rule-Function-COMPLIANCERULESETLATESTINSTALLED
Type: String

Adding a new region

The instructions for adding a new region are not complete. The actual steps are as follows:

  • Update compliance-account-initial-setup.yaml to add the new region and run in the compliance account, in the new region. This will create the s3 codebuild-output bucket for the new region.
  • Create an S3 bucket named config-rule-code-bucket-947791289618-%region%. This should be added to the CFN with an if doesn't exist. Alternatively, you could run rdk init in the new region
  • Update the stack in the main region to include the parameter with the new region being added
  • Invoke the pipeline, the proper lambda's will now be created.
  • Run the application-account-initial-setup.yaml in the child account(s) in the new region

It should also be noted, if creating multiple regions at the beginning, all of the above needs to happen as well. Additionally, the defaults are for the "other regions" to only receive "otherregionsbaseline" tagged rules. Recommend that we change this to the same "baseline" tag as default.

I will fork the repo this weekend and create pull requests with new readme and the bucket creation that is missin

getting python error

when deploying the Compliance account setup pipeline, im getting an error

[Container] 2019/10/18 19:43:33 Running command if [ "$OTHER_ACTIVE_REGIONS" != "none" ]; then chmod a+x ./rulesets-build/multi-region/deploy_lambda.sh; ./rulesets-build/multi-region/deploy_lambda.sh $OTHER_ACTIVE_REGIONS $ENGINE_RULE_NAME $AWS_DEFAULT_REGION; fi
Deploy in us-east-2
Traceback (most recent call last):
File "/usr/local/bin/rdk", line 11, in
load_entry_point('rdk==0.6.1', 'console_scripts', 'rdk')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/init.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/init.py", line 2693, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/init.py", line 2324, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/init.py", line 2330, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.6/site-packages/rdk/cli.py", line 13, in
from rdk import rdk
File "/usr/local/lib/python3.6/site-packages/rdk/rdk.py", line 686
<<<<<<< HEAD
^
IndentationError: expected an indented block

An error occurred (ResourceNotFoundException) when calling the UpdateFunctionConfiguration operation: Function not found: arn:aws:lambda:us-east-2:788247333161:function:RDK-Rule-Function-COMPLIANCERULESETLATESTINSTALLED

Failed to deploy datalake

Template validation error: Parameter SourceLambdaBucket failed to satisfy constraint: Enter the name not the ARN, must be in the same region than the stack

is the error when one tries to deploy the CFN template.

screen shot 2018-03-21 at 23 26 19

Compliance-Engine-Pipeline successful when it fails to assume a role

Hi,

While configuring this in a single account and multi account environment, I noticed that the Compliance-Engine-Pipeline pipeline is successful even though Compliance-Rule-Template-Deploy process is not successful if it can't assume a role.

> [Container] 2020/02/01 16:16:53 Running command python ./deploy_rule_templates.py $AWS_DEFAULT_REGION $OUTPUT_BUCKET_NO_REGION $ENGINE_RULE_NAME $OTHER_ACTIVE_REGIONS
> Failed to assume role into remote account. An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::XXXXXXXXXXXX:assumed-role/ComplianceEngine-CodeBuildRole/AWSCodeBuild-713a7773-7e20-4212-bfa4-0206631304cb is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::XXXXXXXXXXXX:role/service-role/AWSConfigAndComplianceAuditRole-DO-NOT-DELETE
> 
> [Container] 2020/02/01 16:16:55 Phase complete: POST_BUILD State: SUCCEEDED

Not sure if this is specific to my situation, ideally it should fail the build

Compliance-Engine-benchmark stack not created when AWS Config set to false

When running the application account CFN, and an existing delivery channel (aws config set to false) a number of things don't run. I've been working through some of those things (role creation) but one thing that does not get run is the Compliance-Engine-Benchmark stack.

Would like a way to get everything run in the application account when the config/delivery channel already exists.

--pk

Initial Deployment issue

I setup the compliance and the application account yamls in the same region but I did add additional regional support in the compliance account. Both CFT's ran successfully. The code pipeline failed to deploy config rule successfully. I have the out error below.

[Container] 2019/06/21 00:25:57 Running command python ./deploy_rule_templates.py $AWS_DEFAULT_REGION $OUTPUT_BUCKET_NO_REGION $ENGINE_RULE_NAME $OTHER_ACTIVE_REGIONS
Skipping default.json
Skipping rulesets_list.txt
Traceback (most recent call last):
File "./deploy_rule_templates.py", line 31, in
default_template = json.loads(default_template_obj.get()['Body'].read().decode('utf-8'))
File "/usr/local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in call
response = getattr(parent.meta.client, operation_name)(**params)
File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 623, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchBucket: An error occurred (NoSuchBucket) when calling the GetObject operation: The specified bucket does not exist

[Container] 2019/06/21 00:25:59 Command did not exit successfully python ./deploy_rule_templates.py $AWS_DEFAULT_REGION $OUTPUT_BUCKET_NO_REGION $ENGINE_RULE_NAME $OTHER_ACTIVE_REGIONS exit status 1
[Container] 2019/06/21 00:25:59 Phase complete: BUILD State: FAILED
[Container] 2019/06/21 00:25:59 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: python ./deploy_rule_templates.py $AWS_DEFAULT_REGION $OUTPUT_BUCKET_NO_REGION $ENGINE_RULE_NAME $OTHER_ACTIVE_REGIONS. Reason: exit status 1

Hitting limit on change set

Situation:

  • The pipeline runs every hour
  • The datalake is deployed

Challenges:

  • After 30 days or so, the pipeline fails due to hitting the change set limit on the datalake CFn.

Reason:

  • The datalake gets a change set created everytime the pipeline runs. If no change, the number of change set keep growing.

Workaround:

  • delete the change sets manually on the datalake CFn
  • Re-run the pipeline

Add Rule Fails

I added a new manager rule to the pipeline and it is failing during the buildruletemplate phase. Below is the error message. I am not sure what I am missing here. I also have a copy of the json parameters file below.

[Container] 2019/07/09 16:39:21 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: rdk deploy -f --all > ../result.txt. Reason: exit status 1

{
"Version": "1.0",
"Parameters": {
"RuleName": "REQUIRED_TAGS",
"SourceRuntime": null,
"CodeKey": null,
"InputParameters": "{}",
"OptionalParameters": "{}",
"SourcePeriodic": "TwentyFour_Hours",
"SourceIdentifier": "REQUIRED_TAGS",
"RuleSets": "baseline"
},
"Tags": "[DefaultRuleSet]"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.