-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: give cicd role permissions on eks cluster
- Loading branch information
Showing
5 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,26 +25,25 @@ jobs: | |
- name: format | ||
run: npm run format -- --fix=false # ensure eslint is not configured to --fix | ||
|
||
|
||
# - name: Setup kubectl | ||
# uses: azure/setup-kubectl@v3 | ||
# with: | ||
# version: 'latest' | ||
|
||
# - name: AWS Configure | ||
# uses: aws-actions/[email protected] | ||
# with: | ||
# aws-region: ap-southeast-2 | ||
# mask-aws-account-id: true | ||
# role-to-assume: ${{ secrets.AWS_CI_ROLE }} | ||
- name: AWS Configure | ||
uses: aws-actions/[email protected] | ||
with: | ||
aws-region: ap-southeast-2 | ||
mask-aws-account-id: true | ||
role-to-assume: ${{ secrets.AWS_CI_ROLE }} | ||
|
||
# - name: Login to EKS | ||
# run: | | ||
# aws eks update-kubeconfig --name Workflow --region ap-southeast-2 --role-arn ${{ secrets.AWS_EKS_ROLE }} | ||
- name: Login to EKS | ||
run: | | ||
aws eks update-kubeconfig --name Workflow --region ap-southeast-2 | ||
# - name: Check EKS connection | ||
# run: | | ||
# kubectl get nodes | ||
- name: Check EKS connection | ||
run: | | ||
kubectl get nodes | ||
# - name: Install Argo | ||
# run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Arn, ArnComponents, ArnFormat } from 'aws-cdk-lib'; | ||
import { Node } from 'constructs'; | ||
|
||
/** | ||
* Validate that a object is a AWS IAM role arn | ||
* | ||
* @param arn arn to validate | ||
* @returns ARN if valid | ||
* @throws {Error} If ARN is not for a AWS IAM Role | ||
*/ | ||
export function validateRoleArn(arn: unknown): ArnComponents { | ||
if (typeof arn !== 'string') throw new Error('Failed to parse ARN, is not a string'); | ||
if (arn.includes('*')) throw new Error(`ARN cannot include "*" ${arn}`); | ||
try { | ||
const components = Arn.split(arn, ArnFormat.SLASH_RESOURCE_NAME); | ||
if (components.service !== 'iam') throw new Error('ARN is not a iam service'); | ||
if (components.resource !== 'role') throw new Error('ARN is not a role'); | ||
return components; | ||
} catch (e) { | ||
throw new Error(`Failed to parse ARN: "${arn}"`, { cause: e }); | ||
} | ||
} | ||
|
||
/** | ||
* Lookup a role ARN from context | ||
* | ||
* @returns arn if its valid, null otherwise | ||
* @throws {Error} If arn is invalid | ||
*/ | ||
export function tryGetContextArn(node: Node, context: string): string | null { | ||
const ctx = node.tryGetContext(context); | ||
if (ctx == null) return null; | ||
validateRoleArn(ctx); | ||
return ctx; | ||
} | ||
|
||
/** | ||
* | ||
* Lookup a list of role ARNs from context | ||
* | ||
* @throws {Error} If any arn is invalid | ||
* @returns arns if they are valid, null otherwise | ||
*/ | ||
export function tryGetContextArns(node: Node, context: string): string[] | null { | ||
const ctx = node.tryGetContext(context); | ||
if (ctx == null) return null; | ||
if (!Array.isArray(ctx)) throw new Error('Failed to parse ARN, is not a string[]'); | ||
for (const arn of ctx) validateRoleArn(arn); | ||
return ctx; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters