The External Secrets Inc. Audit & Compliance product suite is a premium product. It requires a specific subscription. Contact us for more information.

AWS Parameter Store Provider

The Audit Listener can be configured to receive audit logs from AWS Parameter Store by utilizing a SQS queue, Event Bridge and a Cloud Trail. The illustration below demonstrates the setup: Architecture Light Architecture Dark

Required Permissions

To setup the Listener, the following permission must be assigned:
  • sqs:ReceiveMessage
  • sqs:DeleteMessage
  • ssm:GetParametersByPath
  • ssm:GetParameter
  • kms:Decrypt
The GetParameter, GetParametersByPath and Decrypt permissions are necessary for the listener to calculate duplicate entries.

Policy Example

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "SSMParameterReadAccess",
      "Effect": "Allow",
      "Action": [
        "ssm:GetParameter",
        "ssm:GetParametersByPath"
      ],
      "Resource": "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/*"
    },
    {
      "Sid": "KMSDecryptAccess",
      "Effect": "Allow",
      "Action": "kms:Decrypt",
      "Resource": "arn:aws:kms:<REGION>:<ACCOUNT_ID>:key/<YOUR_KEY_ID>"
    }
  ]
}

Configuring the Provider

Setting up the provider may require configuration of the authentication methods during the listener installation process.

Supported Authentication Methods

The Audit Listener supports the following AWS authentication methods:
  • Using a Access Key and Secret Access Key defined in the runtime.
  • Using an IAM role for tasks when using ECS task definition or the RunTask API operation.
  • Using an IAM role for Amazon EC2 when your is running on an EC2 instance.
  • Using IAM Role for Service Account when running on EKS.

Creating a new Provider

After completing the listener setup, you can create a new provider.
  1. Navigate to the Dashboard.
  2. Add a new provider:
    • Select AWS_PARAMETER_STORE as the provider type.
    • Specify the fields based on your installation:
      • Region: AWS region.
      • QueueURL: SQS queue endpoint URL.

Setting Up AWS

  • Create S3 Bucket that will be used to store Cloud Trail logs
  • Create a Trail on Cloud Trail
  • Create SQS queue that will be consumed by Audit Listener
  • Configure Event Bridge to route Parameter Store events to SQS

Create S3 Bucket

data "aws_caller_identity" "current" {}

resource "aws_s3_bucket" "ps_trail_bucket" {
  bucket = "ps-trail-bucket"
}

resource "aws_s3_bucket_policy" "s3_bucket_policy" {
  bucket = aws_s3_bucket.ps_trail_bucket.id
  policy = jsonencode({
    Version = "2012-10-17",
    Statement = [

      {
        Sid       = "AWSCloudTrailAclCheck",
        Effect    = "Allow",
        Principal = { Service = "cloudtrail.amazonaws.com" },
        Action    = "s3:GetBucketAcl",
        Resource  = aws_s3_bucket.ps_trail_bucket.arn
      },
      {
        Sid       = "AWSCloudTrailWrite",
        Effect    = "Allow",
        Principal = { Service = "cloudtrail.amazonaws.com" },
        Action    = "s3:PutObject",
        Resource  = "${aws_s3_bucket.ps_trail_bucket.arn}/AWSLogs/${data.aws_caller_identity.current.account_id}/*"
      }
    ]
  })
}

Create Trail

resource "aws_cloudtrail" "cloud_trail" {
  name                          = "ps-trail"
  s3_bucket_name                = aws_s3_bucket.ps_trail_bucket.id
  include_global_service_events = true
  is_multi_region_trail         = true
  enable_log_file_validation    = true
}

Create SQS Queue


resource "aws_sqs_queue" "ps_events_queue" {
  name = "parameter_store_events"
}

data "aws_iam_policy_document" "policy" {
  statement {
    actions   = ["sqs:SendMessage"]
    resources = [aws_sqs_queue.ps_events_queue.arn]
    sid       = "AllowEventBridgeToSendMessages"
    principals {
      type        = "Service"
      identifiers = ["events.amazonaws.com"]
    }
    condition {
      test     = "ArnEquals"
      variable = "aws:SourceArn"
      values   = [aws_cloudwatch_event_rule.ps_events_rule.arn]
    }
    effect = "Allow"
  }
}

resource "aws_sqs_queue_policy" "sqs_policy" {
  queue_url = aws_sqs_queue.ps_events_queue.id

  policy = data.aws_iam_policy_document.policy.json
}

Configure Event Bridge

resource "aws_cloudwatch_event_rule" "ps_events_rule" {
  name = "parameter-store-events-rule"

  event_pattern = jsonencode({
    source      = ["aws.ssm"],
    detail-type = ["AWS API Call via CloudTrail"],
    "detail" : {
      "eventSource" : ["ssm.amazonaws.com"]
    }
  })
  ## For GetSecretValue Logging
  state = "ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS"
}

resource "aws_cloudwatch_event_target" "sqs" {
  rule      = aws_cloudwatch_event_rule.ps_events_rule.name
  target_id = "SendToSQS"
  arn       = aws_sqs_queue.ps_events_queue.arn
}