- Sign in to the AWS Management Console using an account with permissions to create IAM roles and attach policies.
- Use the search bar to locate the IAM service and select it.
- In the IAM Dashboard, select Roles from the left sidebar menu.
- Click the Create role button.
- In the Trusted entity type section, select Custom trust policy.
- In the code editor that appears below, paste the following JSON policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "FluidAttacksAccess",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "sts:AssumeRole",
"Condition": {
"ArnEquals": {
"aws:PrincipalArn": "arn:aws:iam::205810638802:role/prod_integrates"
},
"StringEquals": {
"sts:ExternalId": "<YOUR-EXTERNAL-ID>"
}
}
}
]
}
Replace
<YOUR-EXTERNAL-ID> with the
external ID that Fluid Attacks generated for your organization.
Trust policy breakdown
The trust policy above contains four key elements:
- Principal (
"AWS": "*" ): Although this field allows any AWS account to assume the role, the conditions below restrict actual access. - Action (
sts:AssumeRole ): This action permits external entities to assume the role. - Condition (
aws:PrincipalArn ): This condition restricts role assumption exclusively to Fluid Attacks' production role (arn:aws:iam::205810638802:role/prod_integrates). - Condition (
sts:ExternalId ): This shared secret between Fluid Attacks and your organization verifies that assumption requests genuinely originate from Fluid Attacks, preventing unauthorized access.
Assign permissions to the role
- Click Next to proceed to the permissions configuration. You may select the ReadOnlyAccess permission, but Step 8 shows you a recommended user-managed policy used to clone CodeCommit repositories.
- Create or attach a policy that grants access to your CodeCommit repositories. To follow the principle of least privilege, this is the policy Fluid Attacks recommends:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CodeCommitAccess",
"Effect": "Allow",
"Action": ["codecommit:Get*", "codecommit:GitPull"],
"Resource": ["<REPO-ARN>"]
}
]
}
Replace <REPO-ARN> with the actual ARN of your repository. To grant access to multiple repositories, add their ARNs to the Resource array.
- Click Next to review your role configuration.
- Provide a name for the role (e.g.,
FluidAttacksCodeCommit) and add a description. - Click Create role to finish the setup.
- Locate your new role in the IAM roles list and click on it to view its details.
- Copy the ARN (Amazon Resource Name) displayed at the top of the role summary. You need this value to complete the configuration in the Fluid Attacks platform.
You can automate the role creation process using AWS CloudFormation. This method is ideal for infrastructure-as-code workflows and multi-account deployments.
First, create the template, then, deploy it using either of the following options:
- AWS CLI
- AWS Management Console
- Create a new file with a .yaml extension.
- Copy the following CloudFormation template into the file:
Resources:
CodeCommitAccessRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Principal:
AWS:
- "*"
Condition:
ArnEquals:
aws:PrincipalArn: "arn:aws:iam::205810638802:role/prod_integrates"
StringEquals:
sts:ExternalId: "<YOUR-EXTERNAL-ID>"
Description: Role to grant Fluid Attacks access to CodeCommit repositories
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSCodeCommitReadOnly
RoleName: FluidAttacksCodeCommit
- Replace
<YOUR-EXTERNAL-ID> with the external ID that Fluid Attacks generated for your organization. - Save the file.
This template uses the AWSCodeCommitReadOnly managed policy for simplicity.
Deploy using the AWS CLI
- Install the AWS CLI if you have not already done so.
- Configure your security credentials (
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) for a user with permissions to create CloudFormation stacks and IAM resources. - Run the following command to deploy the stack:
aws cloudformation deploy --template-file <path/to/template.yaml> \
--stack-name <stack-name> \
--capabilities CAPABILITY_NAMED_IAM
Replace <path/to/template.yaml> with the path to your template file and <stack-name> with a descriptive name (e.g., fluid-attacks-codecommit).
- After the deployment completes, retrieve the role ARN by running this:
aws iam get-role --role-name "FluidAttacksCodeCommit"
The command returns a JSON response containing the role details, including the ARN.
Deploy using the AWS Management Console
- Sign in to the AWS Management Console using an account with permissions to perform read and write operations for CloudFormation and IAM resources.
- Use the search bar to locate the CloudFormation service and select it.
- In the CloudFormation Dashboard, click the Create stack dropdown and select With new resources (standard).
- Under Prerequisite - Prepare template, select Template is ready and, under Specify template, select Upload a template file, then click Choose file and select the template you created.
- Click Next to proceed.
- Enter a name for the stack and click Next.
- On the Configure stack options page, you can leave the default settings. Click Next.
- On the review page, scroll to the Capabilities section at the bottom and check the box acknowledging that CloudFormation may create IAM resources with custom names.
- Click Submit to begin the deployment and wait for the stack status to show 'CREATE_COMPLETE'.
- Navigate to the Resources tab and click the Physical ID link for the role resource. This redirects you to the IAM Dashboard.
- Copy the ARN from the role summary to use in the Fluid Attacks platform.
Troubleshooting
If you encounter issues when adding your AWS environment to the Fluid Attacks platform, verify the following: