Skip to content
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
337 changes: 337 additions & 0 deletions deploy/cloudformation/federated-identity-aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: 'Creates an IAM Role for Elastic Federated Identity (Cloud Connectors). Grants read-only permissions for all Elastic AWS integrations that support Federated Identity: the aws package integrations (GuardDuty, Inspector, Config, CloudWatch, and metrics services), Cloud Security Posture Management (cloud_security_posture), and Cloud Asset Inventory (cloud_asset_inventory).'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: 'Creates an IAM Role for Elastic Federated Identity (Cloud Connectors). Grants read-only permissions for all Elastic AWS integrations that support Federated Identity: the aws package integrations (GuardDuty, Inspector, Config, CloudWatch, and metrics services), Cloud Security Posture Management (cloud_security_posture), and Cloud Asset Inventory (cloud_asset_inventory).'
Description: 'Creates an IAM Role for Elastic Identity Federation. Grants read-only permissions for all Elastic AWS integrations that support Identity Federation: the AWS package integrations (GuardDuty, Inspector, Config, CloudWatch, and metrics services)'


Parameters:
ElasticResourceId:
Description: The Elastic resource ID (deployment component ID or serverless project ID) that the role will trust.
Type: String

ElasticRoleARN:
Description: Elastic's super-role ARN. Change only for test environments.
Type: String
Default: arn:aws:iam::254766567737:role/cloud_connectors

Resources:

# Grants live in two places, both mirroring the provider_permissions
# declared in each integration's package manifest (elastic/integrations):
# managed policies (`roles`) go on the role's ManagedPolicyArns; inline
# permissions get one AWS::IAM::Policy resource per federated integration.
# Add grants only when an integration gains Federated Identity support —
# never ahead of a declaration.
ElasticFederatedIdentityRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub ElasticFederatedIdentity-${AWS::StackName}
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS: !Ref ElasticRoleARN
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: !Join
- '-'
- - !Ref ElasticResourceId
- !Select
- 2
- !Split
- /
- !Ref AWS::StackId
Path: /
ManagedPolicyArns:

# aws/guardduty: pre-dates provider_permissions; grant carried over
# from the shipped cloud-connectors-guardduty template.
- arn:aws:iam::aws:policy/AmazonGuardDutyReadOnlyAccess

# cloud_security_posture (CSPM) and cloud_asset_inventory (CAI):
# both require SecurityAudit for broad read-only access to AWS config
# and resource metadata. Consolidates the grants previously split across
# deploy/cloudformation/cloud-connectors-remote-role.yml (CSPM) and
# deploy/asset-inventory-cloudformation/cloud-connectors-remote-role.yml (CAI).
- arn:aws:iam::aws:policy/SecurityAudit

# aws/inspector: inspector2 data stream
ElasticAwsInspector:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsInspector-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- inspector2:ListFindings
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/cloudwatch: cloudwatch_logs (aws-cloudwatch) and cloudwatch_metrics (aws/metrics)
# Also covers ec2_logs, elb_logs, lambda_logs via the shared aws-cloudwatch input
ElasticAwsCloudwatchLogs:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsCloudwatchLogs-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:DescribeLogGroups
- logs:FilterLogEvents
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# Shared base for all aws/metrics metricsets (cloudwatch, ec2, elb, lambda, rds, etc.)
ElasticAwsMetrics:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsMetrics-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeRegions
- cloudwatch:ListMetrics
- cloudwatch:GetMetricData
- tag:GetResources
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/awshealth: health events data stream
ElasticAwsHealth:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsHealth-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- health:DescribeEvents
- health:DescribeEventDetails
- health:DescribeAffectedEntities
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/config: rule listing and per-rule compliance reads for the AWS Config data stream
ElasticAwsConfig:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsConfig-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- config:DescribeConfigRules
- config:GetComplianceDetailsByConfigRule
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/billing: billing metrics data stream
ElasticAwsBilling:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsBilling-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ce:GetCostAndUsage
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/dynamodb: dynamodb metrics data stream
ElasticAwsDynamoDB:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsDynamoDB-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- dynamodb:ListTables
- dynamodb:DescribeTable
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/ebs: ebs metrics data stream
ElasticAwsEBS:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsEBS-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeVolumes
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/ec2: ec2_metrics data stream
ElasticAwsEC2:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsEC2-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeInstances
- ec2:DescribeInstanceStatus
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/ecs: ecs_metrics data stream
ElasticAwsECS:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsECS-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ecs:ListClusters
- ecs:DescribeClusters
- ecs:ListServices
- ecs:DescribeServices
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/elb: elb_metrics data stream
ElasticAwsELB:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsELB-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- elasticloadbalancing:DescribeLoadBalancers
- elasticloadbalancing:DescribeTargetGroups
- elasticloadbalancing:DescribeTargetHealth
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/lambda: lambda metrics data stream
ElasticAwsLambda:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsLambda-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- lambda:ListFunctions
- lambda:GetFunction
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/rds: rds metrics data stream
ElasticAwsRDS:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsRDS-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- rds:DescribeDBInstances
- rds:DescribeDBClusters
- rds:ListTagsForResource
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/sns: sns metrics data stream
ElasticAwsSNS:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsSNS-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- sns:ListTopics
- sns:GetTopicAttributes
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/sqs: sqs metrics data stream
ElasticAwsSQS:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsSQS-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- sqs:ListQueues
- sqs:GetQueueAttributes
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

# aws/transitgateway: transitgateway metrics data stream
ElasticAwsTransitGateway:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsTransitGateway-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeTransitGateways
- ec2:DescribeTransitGatewayAttachments
Resource: '*'
Roles:
- !Ref ElasticFederatedIdentityRole

Outputs:
RoleArn:
Description: The ARN of the IAM Role. Paste this into Kibana.
Value: !GetAtt ElasticFederatedIdentityRole.Arn

ExternalId:
Description: The External ID used in the trust policy. Paste this into Kibana.
Value: !Join
- '-'
- - !Ref ElasticResourceId
- !Select
- 2
- !Split
- /
- !Ref AWS::StackId

StackId:
Description: Store this in Kibana to construct stack-update URLs later.
Value: !Ref AWS::StackId
3 changes: 3 additions & 0 deletions scripts/publish_cft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ upload_file deploy/asset-inventory-cloudformation/cloud-connectors-remote-role-o
upload_file deploy/cloudformation/cloud-connectors-guardduty.yml \
"cloudformation-cloud-connectors-guardduty" \
"${version}"
upload_file deploy/cloudformation/federated-identity-aws.yml \
"cloudformation-federated-identity-aws" \
"${version}"
Loading