BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeAWS Certified DevOps Engineer - Professional (DOP-C02)Security Configurations for Log Collection: IAM & Permissions
Study Guide985 words

Security Configurations for Log Collection: IAM & Permissions

Security configurations (for example, IAM roles and permissions to allow for log collection)

Security Configurations for Log Collection: IAM & Permissions

This guide covers the critical security configurations required to enable robust logging and auditing within an AWS environment, specifically focusing on IAM roles, resource-based policies, and cross-account log aggregation for the AWS Certified DevOps Engineer Professional exam.

Learning Objectives

After studying this guide, you should be able to:

  • Configure IAM Roles for EC2 instances and on-premises servers to securely transmit logs to CloudWatch and S3.
  • Design Resource-based Policies that allow services like VPC Flow Logs and CloudTrail to write to centralized buckets.
  • Implement Cross-Account Logging using IAM roles and STS for centralized security auditing.
  • Apply KMS Encryption to logs at rest and in transit while ensuring the principal has the necessary key permissions.

Key Terms & Glossary

  • IAM Role: An identity you can create in your account that has specific permissions but no permanent credentials.
  • Trust Policy: A JSON policy document that defines which principals (services or accounts) can assume the role.
  • Service-Linked Role (SLR): A unique type of IAM role that is linked directly to an AWS service, predefined by the service for specific actions (e.g., Security Hub).
  • Log Destination: An AWS resource (like a Kinesis stream or S3 bucket) configured to receive logs from another source.
  • IAM PassRole: A permission that allows a user to pass an IAM role to an AWS service (e.g., passing a role to an EC2 instance).

The "Big Idea"

In a distributed DevOps environment, visibility is the foundation of security. However, the mechanism used to collect visibility data (logs) must itself be secure. If the logging pipeline is misconfigured, an attacker could disable logging to hide their tracks or exfiltrate sensitive data via the log stream. Secure configuration ensures that only authorized entities can write logs and that those logs remain immutable and encrypted.

Formula / Concept Box

ConceptRequirement / RulePurpose
EC2 LoggingIAM Instance ProfileGrants the CloudWatch Agent permission to PutLogEvents.
Cross-Account S3Bucket Policy + IAM RoleAllows Account A to write to Account B's bucket.
KMS + Loggingkms:GenerateDataKeyRequired for the service (e.g., CloudWatch) to encrypt logs.
STS AssumeRolests:AssumeRoleUsed by agents or cross-account processes to get temporary credentials.

Hierarchical Outline

  1. Identity-Based Security for Agents
    • EC2 Instance Profiles: Attaching roles to instances to avoid hardcoding keys.
    • On-Premises Connectivity: Using IAM users with long-term keys or IAM Roles Anywhere for hybrid logging.
  2. Resource-Based Security
    • S3 Bucket Policies: Restricting s3:PutObject to specific VPC CIDRs or service principals.
    • CloudWatch Logs Resource Policies: Allowing Route 53 or Lambda to write logs across accounts.
  3. Cross-Account Collection Patterns
    • Centralized Logging Account: Using a dedicated "Log Archive" account.
    • Organization-level CloudTrail: Aggregating logs from all accounts into one master bucket.
  4. Encryption and Compliance
    • KMS Key Policies: Granting the service principal (e.g., logs.amazonaws.com) the right to use a Customer Managed Key (CMK).

Visual Anchors

Log Collection Architecture

Loading Diagram...
Figure 1 — Mermaid diagram

IAM Role Components

Compiling TikZ diagram…
⏳
Running TeX engine…
This may take a few seconds
Figure 2 — TikZ diagram

Definition-Example Pairs

  • Term: Least Privilege for Logging

  • Definition: Granting only the minimum permissions necessary for an entity to write logs without allowing it to delete or modify existing logs.

  • Example: Creating a policy that allows logs:CreateLogStream and logs:PutLogEvents but explicitly omits logs:DeleteLogGroup or logs:DeleteLogStream.

  • Term: IAM Permissions Boundary

  • Definition: A managed policy that sets the maximum permissions that an identity-based policy can grant to an IAM entity.

  • Example: A DevOps admin creates a boundary for a junior developer that prevents them from creating any role that doesn't include specific logging permissions.

Worked Examples

Scenario: Centralizing CloudTrail Logs

Goal: Configure Account A (Production) to send CloudTrail logs to a bucket in Account B (Security).

Step 1: Create the S3 Bucket in Account B. Enable encryption and versioning on the bucket central-audit-logs-account-b.

Step 2: Apply a Bucket Policy in Account B. This policy allows the CloudTrail service to write to the bucket from Account A.

json
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AWSCloudTrailAclCheck", "Effect": "Allow", "Principal": {"Service": "cloudtrail.amazonaws.com"}, "Action": "s3:GetBucketAcl", "Resource": "arn:aws:s3:::central-audit-logs-account-b" }, { "Sid": "AWSCloudTrailWrite", "Effect": "Allow", "Principal": {"Service": "cloudtrail.amazonaws.com"}, "Action": "s3:PutObject", "Resource": "arn:aws:s3:::central-audit-logs-account-b/AWSLogs/ACCOUNT_A_ID/*", "Condition": {"StringEquals": {"s3:x-amz-acl": "bucket-owner-full-control"}} } ] }

Step 3: Configure CloudTrail in Account A. Specify the S3 bucket from Account B as the destination. CloudTrail uses the service principal, so no additional IAM role is needed on the CloudTrail itself for basic S3 delivery.

Checkpoint Questions

  1. Which IAM policy element allows an EC2 instance to assume a role assigned to it?
  2. To encrypt CloudWatch logs using a Customer Managed Key (CMK), where must the permission to use the key be granted?
  3. What is the difference between an Identity-based policy and a Resource-based policy in the context of S3 logging?
  4. How does sts:AssumeRole differ from iam:PassRole?

[!TIP] Answers: 1. The Trust Policy. 2. In the KMS Key Policy, granting logs.amazonaws.com permission. 3. Identity-based is attached to the user/role; Resource-based is attached to the S3 bucket itself. 4. AssumeRole returns temporary credentials; PassRole allows a service to use a role on your behalf.

Muddy Points & Cross-Refs

  • Confused about KMS permissions? Remember that when a service (like CloudWatch) is performing encryption, the service principal needs permission in the KMS Key Policy, not just the user who created the log group.
  • Logging from On-Premises? Refer to AWS IAM Roles Anywhere to avoid long-term access keys. It uses X.509 certificates to issue temporary credentials.
  • Troubleshooting failed log delivery? Check the S3 Bucket Policy first. If s3:x-amz-acl is missing in the CloudTrail request or the bucket policy requires it, the delivery will fail.

Comparison Tables

Identity-Based vs. Resource-Based Policies

FeatureIdentity-Based PolicyResource-Based Policy
Attached ToIAM User, Group, or RoleS3 Bucket, KMS Key, CW Log Group
PrincipalNot specified (it's the entity it's attached to)Defined in the Principal element
Use CaseGranting a developer access to all logsAllowing a cross-account service to write logs
VisibilityControlled by IAMVisible on the resource itself

[!IMPORTANT] For the DOP-C02 exam, always prioritize Service-Linked Roles over custom roles if the AWS service supports them, as they are managed by AWS and reduce configuration errors.

All AWS Certified DevOps Engineer - Professional (DOP-C02) Study Resources

Related Notes

  • Mastering AWS Alerting and Automated Remediation1,050 words
  • Study Guide: Analyzing Failed Deployments in AWS940 words
  • Incident Analysis: Troubleshooting Failed Processes in AWS1,050 words
  • Mastering AWS Monitoring & Security Analytics: Logs, Metrics, and Findings1,050 words
  • AWS Log Analysis: Athena, CloudWatch Insights, and OpenSearch920 words
  • Analyzing Real-Time Log Streams with Amazon Kinesis Data Streams985 words
  • CloudWatch Anomaly Detection Alarms: Professional Study Guide820 words
  • AWS Application Storage Patterns: EBS, EFS, and S31,054 words
  • Lab: Automating Security Controls and Data Protection with AWS Secrets Manager and Config942 words
  • Master Study Guide: Automating Security Controls & Data Protection (AWS DOP-C02)1,184 words
  • Mastering AWS CloudFormation StackSets: Multi-Account & Multi-Region Orchestration895 words
  • Mastering System Configuration Changes in AWS945 words

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
AWS Certified DevOps Engineer - Professional (DOP-C02) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, top to bottom. EC2 Instance connects to IAM Instance Profile ("1. Assume Role"). B connects to CloudWatch Logs ("2. Permissions"). C connects to Kinesis Data Firehose ("3. Subscription Filter"). D connects to Central S3 Bucket (Security Account) ("4. Cross-Account"). E connects to Access Granted? ("Bucket Policy Check").