1
+ ---
2
+ apiVersion : tekton.dev/v1beta1
3
+ kind : Task
4
+ metadata :
5
+ name : awscli-eks-cfn-launch-template
6
+ namespace : scalability
7
+ spec :
8
+ description : |
9
+ Create an EKS CFN stack to output a launch template.
10
+ This Task can be used to create an EKS CFN stack that outputs a launch template.
11
+ params :
12
+ - name : cluster-name
13
+ description : EKS cluster you want to create CFN stack for.
14
+ - name : stack-name
15
+ description : Stack name you want to spin.
16
+ - name : region
17
+ default : " us-west-2"
18
+ description : The region where the cluster is in.
19
+ - name : kubernetes-version
20
+ default : " 1.28"
21
+ description : The EKS version to install.
22
+ - name : ng-cfn-url
23
+ description : The url of the CFN YAML/JSON to create CFN stack for NG launch template
24
+ - name : endpoint
25
+ default : " "
26
+ workspaces :
27
+ - name : config
28
+ mountPath : /config/
29
+ stepTemplate :
30
+ env :
31
+ - name : KUBECONFIG
32
+ value : /config/kubeconfig
33
+ steps :
34
+ - name : create-launch-template
35
+ image : alpine/k8s:1.23.7
36
+ script : |
37
+ set -x
38
+ ENDPOINT_FLAG=""
39
+ if [ -n "$(params.endpoint)" ]; then
40
+ ENDPOINT_FLAG="--endpoint $(params.endpoint)"
41
+ fi
42
+
43
+ curl -s $(params.ng-cfn-url) -o ./amazon-ng-cfn
44
+
45
+ launch_template_name=$(params.cluster-name)-launchTemplate
46
+ STACK_NAME=$(params.stack-name)
47
+ STACK_STATUS=$(aws cloudformation describe-stacks --query 'Stacks[?StackName==`'${STACK_NAME}'`].StackStatus' --output text --region $(params.region))
48
+
49
+ if [[ "$STACK_STATUS" == "" ]]; then
50
+ aws cloudformation create-stack \
51
+ --stack-name $STACK_NAME \
52
+ --template-body file://$(pwd)/amazon-ng-cfn \
53
+ --parameters ParameterKey=LaunchTemplateName,ParameterValue=$launch_template_name\
54
+ ParameterKey=ClusterName,ParameterValue=$(params.cluster-name)\
55
+ --region $(params.region)
56
+
57
+ aws cloudformation wait stack-create-complete --stack-name $STACK_NAME --region $(params.region)
58
+ echo "CREATED_CFN_STACK=$STACK_NAME"
59
+ else
60
+ echo "$STACK_NAME Already exists"
61
+ fi
0 commit comments