From e033ea9a1e5b6f04b5883006ffde0fc1947f879a Mon Sep 17 00:00:00 2001 From: Kostas Stamatakis Date: Wed, 27 Mar 2024 13:33:33 +0200 Subject: [PATCH] Cloudformation yml to create elast-agent user and generate direct access key --- .../elastic-agent-direct-access-key-cspm.yml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 deploy/cloudformation/elastic-agent-direct-access-key-cspm.yml diff --git a/deploy/cloudformation/elastic-agent-direct-access-key-cspm.yml b/deploy/cloudformation/elastic-agent-direct-access-key-cspm.yml new file mode 100644 index 0000000000..114f646d93 --- /dev/null +++ b/deploy/cloudformation/elastic-agent-direct-access-key-cspm.yml @@ -0,0 +1,48 @@ +AWSTemplateFormatVersion: "2010-09-09" + +Description: Creates elastic-agent cspm user, role, and access key, and outputs the access key + +Parameters: {} + +Resources: + ElasticCSPMUser: + Type: "AWS::IAM::User" + Properties: + UserName: "elasticagent-cspm" + + # IAM Role to assume for Management Account + ElasticCSPMRole: + Type: AWS::IAM::Role + Properties: + RoleName: cloudbeat-root + AssumeRolePolicyDocument: + Version: "2012-10-17" + Statement: + - Effect: Allow + Principal: + AWS: !GetAtt ElasticCSPMUser.Arn + Action: + - sts:AssumeRole + Path: / + ManagedPolicyArns: + - arn:aws:iam::aws:policy/SecurityAudit + + ElasticCSPMAccessKey: + Type: "AWS::IAM::AccessKey" + Properties: + UserName: !Ref ElasticCSPMUser + + +Outputs: + AccessKeyId: + Description: "Access Key ID" + Value: !Ref ElasticCSPMAccessKey + Export: + Name: "AccessKeyId" + + SecretAccessKey: + Description: "Secret Access Key" + Value: !GetAtt ElasticCSPMAccessKey.SecretAccessKey + Export: + Name: "SecretAccessKey" +