Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Lacework ExternalID #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion lambda_functions/source/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def cfn_stack_set_processing(messages):
if not stack_set_instance_exists(config_stack_set_name, acct):
create_stack_instance_list.append(acct)

external_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
external_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=10))
if len(create_stack_instance_list) > 0:
response = create_stack_set_instances(config_stack_set_name, create_stack_instance_list,
param_regions, [
Expand Down
2 changes: 1 addition & 1 deletion lambda_functions/source/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def create(event, context):
existing_cloudtrail = os.environ['existing_cloudtrail']
management_account_id = context.invoked_function_arn.split(":")[4]
region_name = context.invoked_function_arn.split(":")[3]
external_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
external_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=10))

# these env vars are expected to be used for testing only - QA
lacework_custom_sns = os.environ['lacework_custom_sns']
Expand Down
20 changes: 14 additions & 6 deletions templates/lacework-aws-cfg-member.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ Parameters:
Invalid resource name prefix. Must match pattern
^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$
ExternalID:
Default: 4CEBE3B
Default: 4CEBE3BCEB
Copy link

Choose a reason for hiding this comment

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

@jefferyfry what do you think about making this a random string made of the Stack ID you mentioned? would that be a lot to add? should we just leave this as a fixed string?

Description: >-
The cross-account access role created by the stack will use this value for
its ExternalID.
The cross-account access role created by the stack will use this value in
the ExternalID.
Type: String
MinLength: '2'
MaxLength: '1224'
MinLength: '10'
MaxLength: '10'
AllowedPattern: ^[a-zA-Z0-9=,.@:/-]{10}$
ConstraintDescription: >-
Invalid ExternalID value. Must match pattern
^[a-zA-Z0-9=,.@:/-]{10}$. Must be 10 characters long.
LaceworkAccount:
Type: String
Description: "Enter your Lacework account name. Do not include the '.lacework.net' at the end."
MinLength: '1'
LaceworkAWSAccountId:
Type: String
Default: "434813966438"
Expand Down Expand Up @@ -49,6 +57,6 @@ Resources:
- ':root'
Condition:
StringEquals:
'sts:ExternalId': !Ref ExternalID
'sts:ExternalId': !Sub [ 'lweid:aws:v2:${LaceworkAccount}:${AWS::AccountId}:${ExternalID}', { LaceworkAccount: !Ref LaceworkAccount, ExternalID: !Ref ExternalID } ]
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/SecurityAudit'
22 changes: 15 additions & 7 deletions templates/lacework-aws-ct-log.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ Parameters:
Invalid resource name prefix value. Must match pattern
^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$
ExternalID:
Default: 4CEBE3B
Default: 4CEBE3BCEB
Description: >-
The cross-account access role created by the stack will use this value for
its ExternalID.
The cross-account access role created by the stack will use this value in
the ExternalID.
Type: String
MinLength: '2'
MaxLength: '1224'
MinLength: '10'
MaxLength: '10'
AllowedPattern: ^[a-zA-Z0-9=,.@:/-]{10}$
ConstraintDescription: >-
Invalid ExternalID value. Must match pattern
^[a-zA-Z0-9=,.@:/-]{10}$. Must be 10 characters long.
LaceworkAccount:
Type: String
Description: "Enter your Lacework account name. Do not include the '.lacework.net' at the end."
MinLength: '1'
ExistingTrailBucketName:
Description: >-
Provide the name of the S3 bucket for your existing trail setup. The
Expand Down Expand Up @@ -71,7 +79,7 @@ Resources:
- ':root'
Condition:
StringEquals:
'sts:ExternalId': !Ref ExternalID
'sts:ExternalId': !Sub [ 'lweid:aws:v2:${LaceworkAccount}:${AWS::AccountId}:${ExternalID}', { LaceworkAccount: !Ref LaceworkAccount, ExternalID: !Ref ExternalID } ]
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/SecurityAudit'
LaceworkCWSPolicy:
Expand Down Expand Up @@ -153,7 +161,7 @@ Outputs:
- Arn
ExternalID:
Description: ExternalID to share with Lacework for CloudTrail integration
Value: !Ref ExternalID
Value: !Sub [ 'lweid:aws:v2:${LaceworkAccount}:${AWS::AccountId}:${ExternalID}', { LaceworkAccount: !Ref LaceworkAccount, ExternalID: !Ref ExternalID } ]
SQSQueueURL:
Description: SQS queue URL to share with Lacework for CloudTrail Integration
Value: !Ref SqsQueueUrl
Expand Down