implemented EKS infra provisioning with CFN

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba
2021-03-16 17:45:34 -07:00
parent 54a2fe4393
commit 5900ec24ec
6 changed files with 816 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package main
import (
"encoding/json"
"dagger.io/aws"
"dagger.io/aws/cloudformation"
)
#Infrastructure: {
awsConfig: aws.#Config
namePrefix: *"dagger-example-" | string
// Cluster size is 1 for example (to limit resources)
workerNodeCapacity: *1 | >1
workerNodeInstanceType: *"t3.small" | string
let clusterName = "\(namePrefix)eks-cluster"
eksControlPlane: cloudformation.#Stack & {
config: awsConfig
source: json.Marshal(#CFNTemplate.eksControlPlane)
stackName: "\(namePrefix)eks-controlplane"
neverUpdate: true
parameters: ClusterName: clusterName
}
eksNodeGroup: cloudformation.#Stack & {
config: awsConfig
source: json.Marshal(#CFNTemplate.eksNodeGroup)
stackName: "\(namePrefix)eks-nodegroup"
neverUpdate: true
parameters: {
ClusterName: clusterName
ClusterControlPlaneSecurityGroup: eksControlPlane.outputs.DefaultSecurityGroup
NodeAutoScalingGroupDesiredCapacity: 1
NodeAutoScalingGroupMaxSize: NodeAutoScalingGroupDesiredCapacity + 1
NodeGroupName: "\(namePrefix)eks-nodegroup"
NodeInstanceType: workerNodeInstanceType
VpcId: eksControlPlane.outputs.VPC
Subnets: eksControlPlane.outputs.SubnetIds
}
}
}