You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 donot 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.
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:
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].
## Step-07: Update EKS Cluster aws-auth ConfigMap with new role created in previous step
113
193
- We are going to add the role to the `aws-auth ConfigMap` for the EKS cluster.
114
194
- 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.
- rolearn: <ARN of instance role (not instance profile)>
240
+
username: system:node:{{EC2PrivateDNSName}}
241
+
groups:
242
+
- system:bootstrappers
243
+
- system:nodes
244
+
245
+
Save the file.
246
+
247
+
248
+
4. After the file is saved and closed, configmap/aws-auth has been edited. You can check configmap/aws-auth using the command "kubectl describe -n kube-system configmap/aws-auth".
249
+
```
250
+
135
251
## Step-08: Review the buildspec.yml for CodeBuild & Environment Variables
0 commit comments