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

Description: Creates an IAM Role for Elastic Federated Identity (Cloud Connectors). Grants read-only permissions for the Elastic AWS integrations that support Federated Identity, accumulated per integration from each package's declared provider_permissions.

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

# aws/cloudwatch: cloudwatch_logs (aws-cloudwatch input) and cloudwatch_metrics (aws/metrics input)
ElasticAwsCloudwatch:
Type: AWS::IAM::Policy
Properties:
PolicyName: !Sub ElasticAwsCloudwatch-${AWS::StackName}
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:

# cloudwatch_logs — aws-cloudwatch input calls DescribeLogGroups and FilterLogEvents
- logs:DescribeLogGroups
- logs:FilterLogEvents

# cloudwatch_metrics — aws/metrics cloudwatch metricset calls ListMetrics and GetMetricData
- cloudwatch:ListMetrics
- cloudwatch:GetMetricData
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