In the previous section, the policies will be divided into 5 different functions. If you want, you can freely edit and combine them to suit the practical requirements you are aiming for or want to apply.


On the create new screen, we select JSON and fill in our policy specification.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ec2listread",
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:Get*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": [
"us-east-1",
"us-west-1"
]
}
}
}
]
}


Fill in the name with specific description.
ec2-list-readec2-list-read



{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ec2createtags",
"Effect": "Allow",
"Action": "ec2:CreateTags",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:CreateAction": "RunInstances"
}
}
}
]
}


ec2-create-tagsec2-create-tags


Information:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ec2createtagsexisting",
"Effect": "Allow",
"Action": "ec2:CreateTags",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestTag/Team": "Alpha"
},
"ForAllValues:StringEquals": {
"aws:TagKeys": [
"Team",
"Name"
]
}
}
}
]
}





Information:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ec2runinstances",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": [
"us-east-1",
"us-west-1"
],
"aws:RequestTag/Team": "Alpha"
},
"ForAllValues:StringEquals": {
"aws:TagKeys": [
"Name",
"Team"
]
}
}
},
{
"Sid": "ec2runinstancesother",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": [
"arn:aws:ec2:*:*:subnet/*",
"arn:aws:ec2:*:*:key-pair/*",
"arn:aws:ec2:*::snapshot/*",
"arn:aws:ec2:*:*:launch-template/*",
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:placement-group/*",
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*::image/*"
],
"Condition": {
"StringEquals": {
"aws:RequestedRegion": [
"us-east-1",
"us-west-1"
]
}
}
}
]
}





Information:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ec2manageinstances",
"Effect": "Allow",
"Action": [
"ec2:RebootInstances",
"ec2:TerminateInstances",
"ec2:StartInstances",
"ec2:StopInstances"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Team": "Alpha",
"aws:RequestedRegion": [
"us-east-1",
"us-west-1"
]
}
}
}
]
}





After completion, you will have 5 EC2 policies as below:
