Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconaccount-baseline-app
file-type-iconaccount-baseline-root
file-type-iconaccount-baseline-security
file-type-iconauto-update
file-type-iconaws-auth
file-type-iconaws-config-multi-region
file-type-iconaws-config
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconaws-organizations-config-rules
file-type-iconaws-organizations
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconfail2ban
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconsaml-iam-roles
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconaccount-baseline-app
file-type-iconaccount-baseline-root
file-type-iconaccount-baseline-security
file-type-iconauto-update
file-type-iconaws-auth
file-type-iconaws-config-multi-region
file-type-iconaws-config
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconaws-organizations-config-rules
file-type-iconaws-organizations
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconfail2ban
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconsaml-iam-roles
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
AWS Config

AWS Config

Run AWS Config to assess, audit, and evaluate the configurations of your AWS resources, ensuring they meet your compliance requirements.

Code Preview

Preview the Code

mobile file icon

core-concepts.md

down

AWS Config Core Concepts

Background

What is AWS Config?

Config monitors your AWS resources (such as EC2 instances, security groups, EBS volumes, CloudFront Distributions, and a whole lot more) for configuration changes. It tracks these changes over time, and can track whether configurations are in compliance with a standard configuration. If the configuration drifts out of compliance, Config can send a notification. You can view and query Config items in the AWS Config console.

What are Config Rules?

Config rules are expressions of a desired configuration state, written in code and executed as Lambda functions. When a resource configuration changes, AWS Config fires the relevant Lambda functions to evaluate whether the configuration changes the state of compliance with the desired configuration. AWS has developed a set of pre-written rules called AWS Config Managed Rules, but you can also author your own custom rules.

This module enables AWS Config but does not manage or enable any Config Rules.

What resources does this module create?

This module creates the requisite elements to enable AWS Config. The steps include:

  1. (Optional) Create an S3 bucket for Config logs in one or multiple AWS accounts. The bucket is configured to disable public access, to delete log files after a given expiration period, and to use bucket encryption.
  2. Creates a Service-Linked IAM role for AWS Config.
  3. Create a Configuration Recorder.
  4. Create a delivery channel for sending AWS config events to an S3 bucket and (optionally) SNS topic.
  5. Enables the configuration recorder.
  6. (Optional) Creates an aggregator and aggregator authorization to aggregate AWS Config from multiple accounts and regions to a single view.

To implement these steps, this module creates the following resources:

  • aws_s3_bucket: An S3 bucket used by AWS Config to store configuration items.
  • aws_iam_role: A service-linked IAM role allowing the Config service to access the supported AWS resources.
  • aws_config_configuration_recorder: A configuration recorder that records resource configurations.
  • aws_config_delivery_channel: A delivery channel with the previously noted S3 bucket and SNS destinations.
  • aws_config_configuration_recorder_status: A resource to enable the configuration recorder.
  • aws_config_configuration_aggregator: A resource to aggregate AWS Config data from multiple AWS accounts. This is used with multi-account, multi-region configurations.
  • aws_config_aggregate_authorization: A resource to manage an AWS Config Aggregate Authorization. This is used with multi-account, multi-region configurations.

The module does not create and manage Config Rules or Aggregators.

Note: AWS Config must be enabled on a per-region basis. For a complete view of your AWS resources across multiple regions and accounts, use the aws-config-multi-region module.

Day-to-day operations

What does a configuration item look like, and how do I view it?

A configuration item is a JSON-encoded description of configuration change to a resource. Configuration items are delivered by AWS Config each time a resource is created, modified, or deleted. The following snippet is an example of a configuration item (edited for brevity):

{
  "configurationItemDiff": {
    "changedProperties": {
      "Configuration.IpPermissions.1": {
        "updatedValue": {
          "fromPort": 22,
          "ipProtocol": "tcp",
          "toPort": 22,
          "ipv4Ranges": [ { ... } ],
          "ipRanges": [ ... ]
        },
        "changeType": "CREATE"
      },
      "Configuration.IpPermissions.2": {
        "previousValue": null,
        "updatedValue": {
          "fromPort": 80,
          "ipProtocol": "tcp",
          "ipv6Ranges": [],
          "prefixListIds": [],
          "toPort": 80,
          "userIdGroupPairs": [],
          "ipv4Ranges": [ { ... } ],
          "ipRanges": [ ... ]
        },
        "changeType": "CREATE"
      },
      "Configuration.IpPermissions.0": {
        "previousValue": {
          "fromPort": 22,
          "ipProtocol": "tcp",
          "toPort": 22,
          "ipv4Ranges": [ { "cidrIp": "0.0.0.0/0" } ],
          "ipRanges": [ "0.0.0.0/0" ]
        },
        "changeType": "DELETE"
      }
    },
    "changeType": "UPDATE"
  },
  "configurationItem": {
    "relationships": [
      {
        "resourceId": "vpc-09a90003b04281036",
        "resourceName": null,
        "resourceType": "AWS::EC2::VPC",
        "name": "Is contained in Vpc"
      }
    ],
    "configuration": {
      "description": "An Example Security Group",
      "groupName": "ExampleGroup",
      ...
      "groupId": "sg-040febc38b5233298",
      ],
      "vpcId": "vpc-09a90003b04281036"
    },
    "configurationItemVersion": "1.3",
    "configurationItemCaptureTime": "2019-08-22T20:35:49.316Z",
    "configurationStateId": 1566506149316,
    "configurationItemStatus": "OK",
    "resourceType": "AWS::EC2::SecurityGroup",
    "resourceId": "sg-040febc38b5233298",
    "ARN": "arn:aws:ec2:us-east-1::security-group/sg-040febc38b5233298",
    "awsRegion": "us-east-1",
    "configurationStateMd5Hash": "",
  },
  "notificationCreationTime": "2019-08-22T20:35:49.815Z",
  "messageType": "ConfigurationItemChangeNotification",
  "recordVersion": "1.3"
}

The example shows crucial information about how the configuration of a security group has changed. It shows the previous ingress rule configuration, new ingress rule configuration, and the relationship of the security group to other AWS resources, along with some metadata and resource attributes.

How does Config work with multiple accounts across multiple regions?

To have a complete picture of the status of AWS resources, you should configure AWS Config in each region of each of your AWS accounts. Refer to Using AWS Config in multiple regions and accounts for details.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?