Commit bb01a0c 1 parent b6aaee1 commit bb01a0c Copy full SHA for bb01a0c
File tree 3 files changed +21
-13
lines changed
3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change 9
9
"ClusterName" : {
10
10
"Type" : " String" ,
11
11
"Description" : " Name of the Cluster"
12
+ },
13
+ "SSHKeyName" : {
14
+ "Type" : " String" ,
15
+ "Description" : " SSH Key Name for EC2 instances"
12
16
}
13
17
},
14
18
"Resources" : {
17
21
"Properties" : {
18
22
"LaunchTemplateName" : { "Ref" : " LaunchTemplateName" },
19
23
"LaunchTemplateData" : {
24
+ "KeyName" : { "Ref" : " SSHKeyName" },
20
25
"BlockDeviceMappings" : [
21
26
{
22
27
"DeviceName" : " /dev/xvda" ,
Original file line number Diff line number Diff line change 41
41
fi
42
42
43
43
curl -s $(params.ng-cfn-url) -o ./amazon-ng-cfn
44
-
44
+
45
+ SSH_KEY_NAME=scaletest-$(params.region)-nodegroups-ssh-key
46
+ KEY_EXISTS=$(aws ec2 --region $(params.region) describe-key-pairs --key-names $SSH_KEY_NAME --query 'KeyPairs[0].KeyName' --output text)
47
+
48
+ if [[ "$KEY_EXISTS" == "None" ]]; then
49
+ echo "KeyPair not found"
50
+ rm -f $HOME/.ssh/$SSH_KEY_NAME.pem
51
+ # Create the key pair and store it
52
+ aws ec2 create-key-pair --region $(params.region) --key-name $SSH_KEY_NAME --query 'KeyMaterial' --output text > $HOME/.ssh/$SSH_KEY_NAME.pem
53
+ chmod 400 $HOME/.ssh/$SSH_KEY_NAME.pem
54
+ ssh-add -k $HOME/.ssh/$SSH_KEY_NAME.pem
55
+ else
56
+ echo "KeyPair already exists"
57
+ fi
58
+
45
59
launch_template_name=$(params.cluster-name)-launchTemplate
46
60
STACK_NAME=$(params.stack-name)
47
61
STACK_STATUS=$(aws cloudformation describe-stacks --query 'Stacks[?StackName==`'${STACK_NAME}'`].StackStatus' --output text --region $(params.region))
52
66
--template-body file://$(pwd)/amazon-ng-cfn \
53
67
--parameters ParameterKey=LaunchTemplateName,ParameterValue=$launch_template_name\
54
68
ParameterKey=ClusterName,ParameterValue=$(params.cluster-name)\
69
+ ParameterKey=SSHKeyName,ParameterValue=$SSH_KEY_NAME\
55
70
--region $(params.region)
56
71
57
72
aws cloudformation wait stack-create-complete --stack-name $STACK_NAME --region $(params.region)
Original file line number Diff line number Diff line change 69
69
asgs=$((nodes/max_nodes))
70
70
echo "asgs: $asgs"
71
71
node_group=$(params.nodegroup-prefix)$(params.cluster-name)-nodes
72
- SSH_KEY_NAME=scaletest-$(params.region)-nodegroups-ssh-key
73
- if [[ "$(aws ec2 --region $(params.region) describe-key-pairs --key-names $SSH_KEY_NAME --query 'KeyPairs[?KeyName==`'$SSH_KEY_NAME'`].KeyName' --output text)" -eq 0 ]];
74
- then
75
- echo "KeyPair not found";
76
- rm -f $HOME/.ssh/$SSH_KEY_NAME.pem
77
- aws ec2 create-key-pair --region $(params.region) --key-name $SSH_KEY_NAME --query 'KeyMaterial' --output text > $HOME/.ssh/$SSH_KEY_NAME.pem
78
- chmod 400 $HOME/.ssh/$SSH_KEY_NAME.pem
79
- ssh-add -k $HOME/.ssh/$SSH_KEY_NAME.pem
80
- else
81
- echo "KeyPair already exists";
82
- fi
83
72
create_and_validate_dp_nodes()
84
73
{
85
74
node_group_name=$node_group-$1
96
85
--region $(params.region) \
97
86
--instance-types $EC2_INSTANCES \
98
87
--scaling-config minSize=$(params.min-nodes),maxSize=$2,desiredSize=$2 \
99
- --remote-access ec2SshKey=$SSH_KEY_NAME \
100
88
--subnets $NG_SUBNETS $TAINTS_FLAG
101
89
fi
102
90
echo "CREATED_NODEGROUP=$node_group_name"
You can’t perform that action at this time.
0 commit comments