Skip to content

Commit f8f53c5

Browse files
committed
Updated the resource_perimeter_scp to use NotResource
1 parent 7e78b78 commit f8f53c5

File tree

2 files changed

+41
-176
lines changed

2 files changed

+41
-176
lines changed

service_control_policies/README.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,65 +37,22 @@ The following policy statements are included in the SCP examples, each statement
3737
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted resources that include [service_owned_resources](../service_owned_resources.md):
3838

3939
* Resources that belong to your Organizations organization specified by the organization ID (`<my-org-id>`) in the policy statement.
40-
* Resources owned by AWS services. To permit access to service-owned resources through the resource perimeter, two methods are used:
41-
* Relevant service actions are listed in the `NotAction` element of the policy. Actions on resources that allow cross-account access are further restricted in other statements of the policy (`"Sid":"EnforceResourcePerimeterAWSResourcesS3"`, `"Sid":"EnforceResourcePerimeterAWSResourcesSSM"`, `"Sid":"EnforceResourcePerimeterAWSResourcesEC2ImageBuilder"`, `"EnforceResourcePerimeterAWSResourcesECR"`, `"EnforceResourcePerimeterAWSResourcesLambdaLayer"`,`"EnforceResourcePerimeterAWSResourcesEC2PrefixList"`).
42-
* `ec2:Owner` condition key:
43-
* Key value set to `amazon` - Required for your users and applications to be able to perform operations against public images that are owned by [Amazon](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html#iam-example-runinstances-ami) or a [verified partner](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sharing-amis.html#verified-ami-provider) (for example, copying or launching instances using these images).
44-
* Trusted resources that belong to an account outside of your Organizations organization. To permit access to a resource owned by an external account through the resource perimeter, relevant service actions have to be listed in the `NotAction` element of this statement (`<action>`). These actions are further restricted in the `"Sid":"EnforceResourcePerimeterThirdPartyResources"`.
40+
* Resources owned by AWS services. To permit access to service-owned resources through the resource perimeter, relevant resources are listed in the `NotResource` element of the policy. See the [service_owned_resources](../service_owned_resources.md) for a list of resources owned by AWS services.
41+
* Trusted resources that belong to an account outside of your Organizations organization. To permit access to a resource owned by an external account through the resource perimeter, relevant service resources have to be listed in the `NotResource` element of this statement (`<third-party-resource>`). Access to these resources are further restricted in the `"Sid":"EnforceResourcePerimeterThirdPartyResources"`.
4542

4643
### "Sid":"EnforceResourcePerimeterAWSResourcesS3"
4744

4845
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted [Amazon Simple Storage Service (Amazon S3)](https://aws.amazon.com/s3/) resources:
4946

5047
* Amazon S3 resources that belong to your Organizations organization as specified by the organization ID (`<my-org-id>`) in the policy statement.
51-
52-
* Amazon S3 resources owned by AWS services that might be accessed by your identities and applications directly by using your [AWS Identity and Access Management (IAM)](https://aws.amazon.com/iam/) credentials. To account for this access pattern, the `s3:GetObject`, `s3:GetObjectVersion`, `s3:PutObject`, `s3:PutObjectAcl` and `s3:ListBucket` actions are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. The `"Sid":"EnforceResourcePerimeterAWSResourcesS3"` then uses the `aws:ResourceAccount` and `aws:PrincipalTag` condition keys to restrict these actions to resources owned by the AWS service accounts or to IAM principals that have the `dp:exclude:resource:s3` tag set to `true`. See the [service_owned_resources](../service_owned_resources.md) for a list of Amazon S3 resources owned by AWS services.
53-
54-
* Amazon S3 resources owned by AWS services that might be accessed by your identities and applications via AWS services using [forward access sessions (FAS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html). To account for this access pattern, the `s3:GetObject`, `s3:GetObjectVersion`, `s3:PutObject`, and `s3:PutObjectAcl` actions are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. The `"Sid":"EnforceResourcePerimeterAWSResourcesS3"` then uses the aws:CalledVia condition key to restrict these actions to relevant AWS services only. See the [service_owned_resources](../service_owned_resources.md) for a list of Amazon S3 resources owned by AWS services.
55-
56-
57-
### "Sid":"EnforceResourcePerimeterAWSResourcesSSM"
58-
59-
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted [AWS Systems Manager](https://aws.amazon.com/systems-manager/) resources:
60-
61-
* AWS Systems Manager resources that belong to your Organizations organization specified by the organization ID (`<my-org-id>`) in the policy statement.
62-
* AWS Systems Manager resources owned by AWS services that might be accessed by your identities and applications directly by using your IAM credentials. To account for this access pattern, `ssm:Get*`, `ssm:SendCommand`, `ssm:CreateAssociation`, `ssm:StartSession`, `ssm:StartChangeRequestExecution`, `ssm:StartAutomationExecution` are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement.`"Sid":"EnforceResourcePerimeterAWSResourcesSSM"` then uses the `aws:PrincipalTag` condition key with the`dp:exclude:resource:ssm` tag set to `true` to restrict access to these actions to IAM principals tagged for access to resources that do not belong to your organization. See the [service_owned_resources](../service_owned_resources.md) for a list of AWS Systems Manager resources owned by AWS services.
63-
64-
65-
### "Sid":"EnforceResourcePerimeterAWSResourcesEC2ImageBuilder"
66-
67-
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted [EC2 Image Builder](https://aws.amazon.com/image-builder/) resources:
68-
69-
* EC2 Image Builder resources that belong to your Organizations organization specified by the organization ID (`<my-org-id>`) in the policy statement.
70-
* EC2 Image Builder resources owned by AWS services that might be accessed by your identities and applications directly by using your IAM credentials. To account for this access pattern, the `imagebuilder:GetComponent`, `imagebuilder:GetImage` are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. `"Sid":"EnforceResourcePerimeterAWSResourcesImageBuilder"` then uses the `aws:PrincipalTag` condition key with `dp:exclude:resource:imagebuilder` tag set to `true` to restrict access to these actions to IAM principals tagged for access to resources that do not belong to your organization. See the [service_owned_resources](../service_owned_resources.md) for a list of EC2 Image Builder resources owned by AWS services.
71-
72-
### "Sid":"EnforceResourcePerimeterAWSResourcesECR"
73-
74-
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted [Amazon Elastic Container Registry (Amazon ECR)](https://aws.amazon.com/ecr/) resources:
75-
76-
* Amazon ECR repositories that belong to your Organizations organization as specified by the organization ID (`<my-org-id>`) in the policy statement.
77-
* Amazon ECR repositories owned by AWS services that might be accessed by your identities and applications directly by using your IAM credentials. To account for this access pattern, the `ecr:GetDownloadUrlForLayer`and`ecr:BatchGetImage` are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. `"Sid":"EnforceResourcePerimeterAWSResourcesECR"` then uses the `aws:ResourceAccount` condition key to restrict these actions to Amazon ECR repositories owned by the AWS service accounts. See the [service_owned_resources](../service_owned_resources.md) for a list of Amazon ECR repositories owned by AWS services.
78-
79-
### "Sid":"EnforceResourcePerimeterAWSResourcesLambdaLayer"
80-
81-
This policy statement is included in [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted [Lambda](https://aws.amazon.com/lambda/) layers:
82-
83-
* Lambda layers that belong to your AWS Organizations organization as specified by the organization ID (`<my-org-id>`) in the policy statement.
84-
* Lambda layers owned by AWS services that might be accessed by your identities and applications directly by using your IAM credentials. To account for this access pattern, the `lambda:GetLayerVersion` is first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. `"Sid":"EnforceResourcePerimeterAWSResourcesLambdaLayer"` then uses the `aws:ResourceAccount` condition key to restrict these actions to Lambda layers owned by the AWS service accounts. See the [service_owned_resources](../service_owned_resources.md) for a list of Lambda resources owned by AWS services.
85-
86-
### "Sid":"EnforceResourcePerimeterAWSResourcesEC2PrefixList"
87-
88-
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted EC2 prefix lists:
89-
90-
* EC2 managed prefix lists that belong to your Organizations organization specified by the organization ID (`<my-org-id>`) in the policy statement.
91-
* EC2 managed prefix lists owned by AWS services that might be accessed by your identities and applications directly by using your IAM credentials. To account for this access pattern, the `ec2:CreateTags`, `ec2:DeleteTags`, `ec2:GetManagedPrefixListEntries` are first listed in the `NotAction` element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. `"Sid":"EnforceResourcePerimeterAWSResourcesEC2PrefixList"` then uses the `aws:PrincipalTag` condition key with `dp:exclude:resource:ec2` tag set to `true` to restrict access to these actions to IAM principals tagged for access to resources that do not belong to your organization. See the [service_owned_resources](../service_owned_resources.md) for a list of Amazon EC2 resources owned by AWS services.
48+
* Amazon S3 resources owned by AWS services that might be accessed by your identities and applications via AWS services using forward access sessions (FAS). To account for this access pattern, relevant S3 resources are first listed in the NotResource element of the `"Sid":"EnforceResourcePerimeterAWSResources"` statement. The `"Sid":"EnforceResourcePerimeterAWSResourcesS3"` then uses the aws:CalledVia condition key to restrict these access to relevant AWS services only. See the [service_owned_resources](../service_owned_resources.md) for a list of Amazon S3 resources owned by AWS services.
9249

9350
### "Sid":"EnforceResourcePerimeterThirdPartyResources"
9451

9552
This policy statement is included in the [resource_perimeter_scp](resource_perimeter_scp.json) and limits access to trusted resources that include third party resources:
9653

9754
* Resources that belong to your Organizations organization and are specified by the organization ID (`<my-org-id>`) in the policy statement.
98-
* Trusted resources that belong to an account outside of your Organizations organization are specified by account IDs of third parties (`<third-party-account-a>` and `<third-party-account-b>`) in the policy statement. Further restrict access by specifying allowed actions in the Action element of the policy statement. These actions also have to be listed in the `NotAction` element of `"Sid":"EnforceResourcePerimeterAWSResources"`.
55+
* Trusted resources that belong to an account outside of your Organizations organization are specified by account IDs of third parties (`<third-party-account-a>` and `<third-party-account-b>`) in the policy statement. Further restrict access by specifying allowed resources in the Resource element of the policy statement. These resources also have to be listed in the `NotResource` element of `"Sid":"EnforceResourcePerimeterAWSResources"`.
9956

10057
### "Sid":"EnforceNetworkPerimeter"
10158

service_control_policies/resource_perimeter_scp.json

Lines changed: 37 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,54 @@
44
{
55
"Sid":"EnforceResourcePerimeterAWSResources",
66
"Effect":"Deny",
7-
"NotAction":[
8-
"iam:GetPolicy",
9-
"iam:GetPolicyVersion",
10-
"iam:ListEntitiesForPolicy",
11-
"iam:ListPolicyVersions",
12-
"iam:GenerateServiceLastAccessedDetails",
13-
"cloudformation:CreateChangeSet",
14-
"s3:GetObject",
15-
"s3:GetObjectVersion",
16-
"s3:PutObject",
17-
"s3:PutObjectAcl",
18-
"s3:ListBucket",
19-
"ssm:Describe*",
20-
"ssm:List*",
21-
"ssm:Get*",
22-
"ssm:SendCommand",
23-
"ssm:CreateAssociation",
24-
"ssm:StartSession",
25-
"ssm:StartChangeRequestExecution",
26-
"ssm:StartAutomationExecution",
27-
"imagebuilder:GetComponent",
28-
"imagebuilder:GetImage",
29-
"ecr:GetDownloadUrlForLayer",
30-
"ecr:BatchGetImage",
31-
"lambda:GetLayerVersion",
32-
"ec2:CreateTags",
33-
"ec2:DeleteTags",
34-
"ec2:GetManagedPrefixListEntries",
35-
"<action>"
36-
7+
"Action":"*",
8+
"NotResource": [
9+
"arn:aws:iam::aws:policy/*",
10+
"arn:aws:ssm:*::document/*",
11+
"arn:aws:ssm:*::parameter/*",
12+
"arn:aws:ssm:*::automation-definition/*",
13+
"arn:aws:imagebuilder:*:aws:component/*",
14+
"arn:aws:imagebuilder:*:aws:image/*",
15+
"arn:aws:ec2:*::image/*",
16+
"arn:aws:ec2:*:aws:prefix-list/*",
17+
"arn:aws:lambda:*:<service-account-id>:layer:*",
18+
"arn:aws:ecr:*:<service-account-id>:repository/*",
19+
"arn:aws:s3:::aws-glue-studio-transforms-<service-account-id>-prod-<region>/*",
20+
"arn:aws:s3:::elasticbeanstalk-samples-<region>/*",
21+
"arn:aws:s3:::elasticbeanstalk-platform-assets-<region>/*",
22+
"arn:aws:s3:::elasticbeanstalk-env-resources-<region>/*",
23+
"arn:aws:s3:::elasticbeanstalk-<region>/*",
24+
"arn:aws:s3:::jumpstart-cache-prod-<region>/*",
25+
"arn:aws:s3:::jumpstart-cache-prod-<region>",
26+
"arn:aws:cloudformation:*:aws:transform/*",
27+
"arn:aws:s3:::aws-synthetics-library-<unique-identifier>/*",
28+
"arn:aws:s3:::<unique-identifier>aws-data-exchange<unique-identifier>",
29+
"arn:aws:s3:::sc-<product-identifier>-<region>/*",
30+
"arn:aws:s3:::aws-neptune-notebook",
31+
"arn:aws:s3:::aws-neptune-notebook/*",
32+
"arn:aws:s3:::aws-neptune-notebook-<region>",
33+
"arn:aws:s3:::aws-neptune-notebook-<region>/*",
34+
"<third-party-resource>"
3735
],
38-
"Resource":"*",
3936
"Condition":{
4037
"StringNotEqualsIfExists":{
4138
"aws:ResourceOrgID":"<my-org-id>",
42-
"ec2:Owner":"amazon",
4339
"aws:PrincipalTag/dp:exclude:resource": "true"
4440
}
4541
}
4642
},
4743
{
4844
"Sid":"EnforceResourcePerimeterAWSResourcesS3",
4945
"Effect":"Deny",
50-
"Action":[
51-
"s3:GetObject",
52-
"s3:GetObjectVersion",
53-
"s3:PutObject",
54-
"s3:PutObjectAcl",
55-
"s3:ListBucket"
46+
"Action":"*",
47+
"Resource":[
48+
"arn:aws:s3:::<unique-identifier>aws-data-exchange<unique-identifier>",
49+
"arn:aws:s3:::sc-<product-identifier>-<region>/*"
5650
],
57-
"Resource":"*",
5851
"Condition":{
5952
"StringNotEqualsIfExists":{
6053
"aws:ResourceOrgID":"<my-org-id>",
61-
"aws:ResourceAccount": "<glue-account-id>",
62-
"aws:PrincipalTag/dp:exclude:resource": "true",
63-
"aws:PrincipalTag/dp:exclude:resource:s3": "true"
54+
"aws:PrincipalTag/dp:exclude:resource": "true"
6455
},
6556
"ForAllValues:StringNotEquals":{
6657
"aws:CalledVia":[
@@ -70,98 +61,15 @@
7061
}
7162
}
7263
},
73-
{
74-
"Sid": "EnforceResourcePerimeterAWSResourcesSSM",
75-
"Effect": "Deny",
76-
"Action": [
77-
"ssm:SendCommand",
78-
"ssm:CreateAssociation",
79-
"ssm:StartSession",
80-
"ssm:Get*",
81-
"ssm:StartChangeRequestExecution",
82-
"ssm:StartAutomationExecution"
83-
],
84-
"Resource": "*",
85-
"Condition": {
86-
"StringNotEqualsIfExists": {
87-
"aws:ResourceOrgID": "<my-org-id>",
88-
"aws:PrincipalTag/dp:exclude:resource:ssm": "true",
89-
"aws:PrincipalTag/dp:exclude:resource": "true"
90-
}
91-
}
92-
},
93-
{
94-
"Sid": "EnforceResourcePerimeterAWSResourcesEC2ImageBuilder",
95-
"Effect": "Deny",
96-
"Action": [
97-
"imagebuilder:GetComponent",
98-
"imagebuilder:GetImage"
99-
],
100-
"Resource": "*",
101-
"Condition": {
102-
"StringNotEqualsIfExists": {
103-
"aws:ResourceOrgID": "<my-org-id>",
104-
"aws:PrincipalTag/dp:exclude:resource:imagebuilder": "true",
105-
"aws:PrincipalTag/dp:exclude:resource": "true"
106-
}
107-
}
108-
},
109-
{
110-
"Sid": "EnforceResourcePerimeterAWSResourcesECR",
111-
"Effect": "Deny",
112-
"Action": [
113-
"ecr:GetDownloadUrlForLayer",
114-
"ecr:BatchGetImage"
115-
],
116-
"Resource": "*",
117-
"Condition": {
118-
"StringNotEqualsIfExists": {
119-
"aws:ResourceAccount": "<ecr-account-id>",
120-
"aws:ResourceOrgID": "<my-org-id>",
121-
"aws:PrincipalTag/dp:exclude:resource": "true"
122-
}
123-
}
124-
},
125-
{
126-
"Sid": "EnforceResourcePerimeterAWSResourcesLambdaLayer",
127-
"Effect": "Deny",
128-
"Action": [
129-
"lambda:GetLayerVersion"
130-
],
131-
"Resource": "*",
132-
"Condition": {
133-
"StringNotEqualsIfExists": {
134-
"aws:ResourceAccount": "<lambdalayer-account-id>",
135-
"aws:ResourceOrgID": "<my-org-id>",
136-
"aws:PrincipalTag/dp:exclude:resource": "true"
137-
}
138-
}
139-
},
140-
{
141-
"Sid": "EnforceResourcePerimeterAWSResourcesEC2PrefixList",
142-
"Effect": "Deny",
143-
"Action": [
144-
"ec2:CreateTags",
145-
"ec2:DeleteTags",
146-
"ec2:GetManagedPrefixListEntries"
147-
],
148-
"Resource": "*",
149-
"Condition": {
150-
"StringNotEqualsIfExists": {
151-
"aws:ResourceOrgID": "<my-org-id>",
152-
"aws:PrincipalTag/dp:exclude:resource:ec2": "true",
153-
"aws:PrincipalTag/dp:exclude:resource": "true"
154-
}
155-
}
156-
},
15764
{
15865
"Sid":"EnforceResourcePerimeterThirdPartyResources",
15966
"Effect":"Deny",
160-
"Action":"<action>",
161-
"Resource":"*",
67+
"Action":"*",
68+
"Resource":[
69+
"<third-party-resource>"
70+
],
16271
"Condition":{
16372
"StringNotEqualsIfExists":{
164-
"aws:ResourceOrgID":"<my-org-id>",
16573
"aws:PrincipalTag/dp:exclude:resource": "true",
16674
"aws:ResourceAccount": [
16775
"<third-party-account-a>",

0 commit comments

Comments
 (0)