Skip to content

Commit bd0b759

Browse files
author
iru
committed
doc: add use-case for three-way cross-account setup
1 parent 3ca9259 commit bd0b759

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

use-cases/org-existing-cloudtrail-ecs-vpc-subnet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ provider "aws" {
125125
region = "<AWS_REGION>" # must match s3 AND sns region
126126
}
127127
128+
# you can setup this provider as desired, just giving an example
128129
provider "aws" {
129130
alias = "member"
130131
region = "<AWS_REGION>" # must match s3 AND sns region

use-cases/org-three-account-setup.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# OrganizationSetup - Existing Cloudtrail - Three-way cross-account setup
2+
3+
## Use-Case explanation
4+
5+
**Current User Setup**
6+
7+
- AWS Organization Setup
8+
- AWS Organizational Cloudtrail within the managed account, with Cloudtrail-SNS activation + reporting to another member-account S3 bucket
9+
- Existing VPC network setup.
10+
11+
**Sysdig Secure For Cloud [Features](https://docs.sysdig.com/en/docs/installation/sysdig-secure-for-cloud/)**
12+
13+
- Threat-Detection
14+
- Posture; Compliance + Identity Access Management
15+
<br/><br/>
16+
17+
18+
## Suggested setup
19+
20+
We're going to use existing use case [/use-cases/org-existing-cloudtrail-ecs-vpc-subnet.md](./org-existing-cloudtrail-ecs-vpc-subnet.md), with some permission-related changes, due to the three-way cross-account scenario.
21+
This setup is popular with user that are under AWS Control Tower Setup
22+
23+
- Management Account
24+
- the Cloudtrail-SNS
25+
- Log-Archive Account
26+
- the Cloudtrail-S3 bucket
27+
- Member Account
28+
- Sysdig Secure for Cloud deployment
29+
30+
For network setup, please refer to [Sysdig SASS Region and IP Ranges Documentation](https://docs.sysdig.com/en/docs/administration/saas-regions-and-ip-ranges/).
31+
32+
Before proceeding, please read the referenced use-cases and examples and check whether you comply with requirements.
33+
Please contact us if something requires to be adjusted.
34+
35+
36+
### Step by Step Example Guide
37+
38+
<!--
39+
0.1 Provision an S3 bucket in the selected region and allow cloudtrail access
40+
{
41+
"Version": "2012-10-17",
42+
"Statement": [
43+
{
44+
"Sid": "Statement1",
45+
"Effect": "Allow",
46+
"Principal": {
47+
"Service": "cloudtrail.amazonaws.com"
48+
},
49+
"Action": "s3:PutObject",
50+
"Resource": "arn:aws:s3:::irutest-pre-existing-cloudtrail-s3/*"
51+
}
52+
]
53+
}
54+
55+
0.2. Provision an organizational Cloudtrail/SNS in management account and select the previously created S3
56+
-->
57+
58+
59+
1. Configure `AWS_PROFILE` with an organizational Administration credentials
60+
61+
2. Choose an Organizational **Member account for Sysdig Workload** to be deployed.
62+
63+
- This accountID will be provided in the `SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID` parameter
64+
65+
3. Permissions - SNS
66+
67+
- Before running Terraform, we need to give permissions to the role of the `member`-aliased terraform aws provider, to be able to create an SQS queue
68+
and subscribe it to the provided SNS. Otherwise, Terraform will fail with an error such as
69+
> AuthorizationError: User: *** is not authorized to perform: SNS:Subscribe on resource <SNS_ARN>: because no resource-based policy allows the SNS:Subscribe action
70+
- We'll need to add following permissions to the SNS queue
71+
```text
72+
{
73+
"Sid": "AllowSQSSubscribe",
74+
"Effect": "Allow",
75+
"Principal": {
76+
"AWS": "<TERRAFORM_AWS_PROVIDER_MEMBER_ACCOUNT_ROLE_ARN>"
77+
},
78+
"Action": "SNS:Subscribe",
79+
"Resource": "<CLOUDTRAIL_SNS_ARN>"
80+
}
81+
```
82+
83+
4. Use `organizational` example snippet with following parameters
84+
85+
- General
86+
- `AWS_REGION` Same region is to be used for both organizational managed account and Sysdig workload member account resources.<br/>
87+
- **Region MUST match both S3 bucket and SNS Cloudtrail**.
88+
- `SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID` where Sysdig Workload is to be deployed under the pre-existing ECS
89+
90+
- Existing Organizational Cloudtrail Setup
91+
- `CLOUDTRAIL_SNS_ARN`
92+
- `CLOUDTRAIL_S3_ARN`
93+
- You MUST grant manual permissions to the organizational cloudtrail, for the AWS member-account management role `OrganizationAccountAccessRole` to be able to perform `SNS:Subscribe`.
94+
- This will be required for the CloudConnector SQS Topic subscription.
95+
- Use [`./modules/infrastructure/cloudtrail/sns_permissions.tf`](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/modules/infrastructure/cloudtrail/sns_permissions.tf#L22) as guideline
96+
97+
- Existing ECS Cluster Workload Setup
98+
- `ECS_CLUSTER_NAME` ex.: "sfc"
99+
100+
- Existing Networking Setup
101+
- `ECS_VPC_ID` ex.: "vpc-0e91bfef6693f296b"
102+
- `ECS_VPC_SUBNET_PRIVATE_ID_X` Two subnets for the VPC. ex.: "subnet-0c7d803ecdc88437b"
103+
104+
5. Permissions - S3
105+
- Terraform should have successfully deployed everything, but still, ECS task will fail due to missing permissions on S3 access.
106+
- We cannot prepare this beforehand, as S3 will say `Invalid principal in policy` if the referenced Role does not exist yet.
107+
- For cross-account S3 access, we will provision permissions on both management-account role and s3 bucket
108+
- For Terraform provisioned role in the management account, "<ARN_SYSDIG_S3_ACCESS_ROLE>", in form of "arn:aws:iam::<SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID>:role/sysdig-sfc-SysdigSecureForCloudRole", <br/>we will add
109+
```text
110+
{
111+
"Sid": "AllowSysdigReadS3",
112+
"Effect": "Allow",
113+
"Action": [
114+
"s3:GetObject"
115+
],
116+
"Resource": "<ARN_CLOUDTRAIL_S3>/*"
117+
}
118+
```
119+
- For the S3 bucket
120+
```text
121+
{
122+
"Sid": "AllowSysdigToRead",
123+
"Effect": "Allow",
124+
"Principal": {
125+
"AWS": "<ARN_SYSDIG_S3_ACCESS_ROLE>" # role created by terraorm , in form of "arn:aws:iam::<SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID>:role/sysdig-sfc-SysdigSecureForCloudRole"
126+
},
127+
"Action": "s3:GetObject",
128+
"Resource": [
129+
"<CLOUDTRAIL_S3_ARN>",
130+
"<CLOUDTRAIL_S3_ARN>/*"
131+
]
132+
}
133+
```
134+
- We shouldn't need to restart ECS Task for these roles to be effective and logs should show no errors at this point.
135+
136+
### Permission Setup Guidance
137+
138+
![organizational setup](https://github.com/sysdiglabs/aws-templates-secure-for-cloud/raw/main/use_cases/org-k8s/diagram.png)
139+
140+
### Terraform Manifest Snippet
141+
142+
```terraform
143+
terraform {
144+
required_providers {
145+
sysdig = {
146+
source = "sysdiglabs/sysdig"
147+
configuration_aliases = [aws.member]
148+
}
149+
}
150+
}
151+
152+
provider "sysdig" {
153+
sysdig_secure_url = "<SYSDIG_SECURE_URL>"
154+
sysdig_secure_api_token = "<SYSDIG_SECURE_API_TOKEN>"
155+
}
156+
157+
provider "aws" {
158+
region = "<AWS_REGION>" # must match s3 AND sns region
159+
}
160+
161+
# you can setup this provider as desired, just giving an example
162+
# this assumeRole / permission setup is referenced in point #3
163+
provider "aws" {
164+
alias = "member"
165+
region = "<AWS_REGION>" # must match s3 AND sns region
166+
assume_role {
167+
# 'OrganizationAccountAccessRole' is the default role created by AWS for management-account users to be able to admin member accounts.
168+
# if this is changed, please change to the `examples/organizational` input var `organizational_member_default_admin_role` too
169+
# <br/>https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html
170+
role_arn = "arn:aws:iam::<SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID>:role/OrganizationAccountAccessRole"
171+
}
172+
}
173+
174+
module "sysdig-sfc" {
175+
providers = {
176+
aws.member = aws.member
177+
}
178+
179+
source = "sysdiglabs/secure-for-cloud/aws//examples/organizational"
180+
name = "sysdig-sfc"
181+
182+
sysdig_secure_for_cloud_member_account_id="<SYSDIG_SECURE_FOR_CLOUD_MEMBER_ACCOUNT_ID>"
183+
184+
cloudtrail_sns_arn = "<CLOUDTRAIL_SNS_ARN>"
185+
cloudtrail_s3_arn = "<CLOUDTRAIL_S3_ARN>"
186+
187+
ecs_cluster_name = "<ECS_CLUSTER_NAME>"
188+
ecs_vpc_id = "<ECS_VPC_ID>"
189+
ecs_vpc_subnets_private_ids = ["<ECS_VPC_SUBNET_PRIVATE_ID_1>","<ECS_VPC_SUBNET_PRIVATE_ID_2>"]}
190+
```
191+
192+

0 commit comments

Comments
 (0)