Skip to content

Commit d7362b3

Browse files
Updated Trust policy creation using Windows Powershell
Updated Trust policy creation using Windows Powershell
1 parent 07829be commit d7362b3

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

11-DevOps-with-AWS-Developer-Tools/README.md

+81-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,86 @@ aws iam put-role-policy --role-name EksCodeBuildKubectlRole --policy-name eks-de
109109
# Verify the same on Management Console
110110
```
111111

112+
### For Windows users who are using Powershell
113+
```t
114+
Here is a solutions to creating the Trust policy from AWS Tech Support
115+
116+
I understand that you are following an instruction to create an IAM role for CodeBuild but the commands do not work for PowerShell.
117+
118+
In PowerShell, the format is different from the scripts in Mac OS. Cmdlets are used in PowerShell. I have used Cmdlets in PowerShell to create a role and attach an inline policy. Please check the following for the details:
119+
120+
1. Create IAM Role for CodeBuild to Interact with EKS
121+
122+
First create a new file NewRoleTrustPolicy.json with the following contents:
123+
124+
{
125+
126+
"Version": "2012-10-17",
127+
128+
"Statement": [
129+
130+
{
131+
132+
"Sid": "",
133+
134+
"Effect": "Allow",
135+
136+
"Principal": {
137+
138+
"AWS": "arn:aws:iam::xxxxxxxxxxxx:root"
139+
140+
},
141+
142+
"Action": "sts:AssumeRole"
143+
144+
}
145+
146+
]
147+
148+
}
149+
150+
Note: please replace your account ID in the above Principal parameter.
151+
152+
153+
New-IAMRole -AssumeRolePolicyDocument (Get-Content -raw NewRoleTrustPolicy.json) -RoleName EksCodeBuildKubectlRole
154+
155+
After the above command, you can check if the IAM role EksCodeBuildKubectlRole is created in your AWS account. Please check the New-IAMRole Cmdlet reference in [1].
156+
157+
158+
2. Define Inline Policy with eks Describe permission in a file iam-eks-describe-policy
159+
160+
First create a new file iam-eks-describe-policy.json with the following contents:
161+
162+
{ "Version": "2012-10-17",
163+
164+
"Statement":
165+
166+
[ { "Effect": "Allow",
167+
168+
"Action": "eks:Describe*",
169+
170+
"Resource": "*" }
171+
172+
]
173+
174+
}
175+
176+
Write-IAMRolePolicy -RoleName EksCodeBuildKubectlRole -PolicyName eks-describe -PolicyDocument (Get-Content -Raw iam-eks-describe-policy.json)
177+
178+
179+
After the above command, you can check if the IAM role EksCodeBuildKubectlRole has the inline policy eks-describe attached. Please check the Write-IAMRolePolicy Cmdlet reference in [2].
180+
I hope the above information can help you.
181+
182+
References
183+
================
184+
[1]: New-IAMRole
185+
https://docs.aws.amazon.com/powershell/latest/reference/items/New-IAMRole.html
186+
[2]: Write-IAMRolePolicy
187+
https://docs.aws.amazon.com/powershell/latest/reference/items/Write-IAMRolePolicy.html
188+
189+
190+
```
191+
112192
## Step-07: Update EKS Cluster aws-auth ConfigMap with new role created in previous step
113193
- We are going to add the role to the `aws-auth ConfigMap` for the EKS cluster.
114194
- Once the `EKS aws-auth ConfigMap` includes this new role, kubectl in the CodeBuild stage of the pipeline will be able to interact with the EKS cluster via the IAM role.
@@ -362,4 +442,4 @@ kubectl delete -f kube-manifests/
362442
- https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
363443
- https://github.com/aws/aws-codebuild-docker-images/blob/master/al2/x86_64/standard/3.0/Dockerfile
364444
- **STS Assume Role:** https://docs.aws.amazon.com/cli/latest/reference/sts/assume-role.html
365-
- https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_roles.html
445+
- https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_roles.html

0 commit comments

Comments
 (0)