Skip to content

Instantly share code, notes, and snippets.

@Mattsface
Created April 17, 2023 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mattsface/531bf2ea1205f105e77a06d4bf92c139 to your computer and use it in GitHub Desktop.
Save Mattsface/531bf2ea1205f105e77a06d4bf92c139 to your computer and use it in GitHub Desktop.
from pulumi import Config, Output, export, ResourceOptions
import pulumi_aws as aws
import pulumi_cloudinit as cloudinit
import json
cluster = aws.ecs.Cluster("cluster")
text_file = open("cloudinit/add_node.sh", "r")
resource_config = cloudinit.Config("resource",
base64_encode=False,
gzip=False,
parts=[cloudinit.GetConfigPartArgs(
content_type="text/cloud-config",
content=json.dumps(
{
"packages": [
"aws-cfn-bootstrap",
"aws-cli",
"ec2-instance-connect"
],
"mounts": [
"/dev/xvdb",
"none",
"swap",
"sw",
"0",
"0"
],
"bootcmd": [
"mkswap /dev/xvdb",
"swapon /dev/xvdb",
f"echo ECS_CLUSTER=\"{cluster.id}\" >> /etc/ecs/ecs.config",
"echo ECS_ENGINE_AUTH_TYPE=docker >> /etc/ecs/ecs.config",
"echo ECS_ENABLE_CONTAINER_METADATA=true >> /etc/ecs/ecs.config"
],
"runcmd": [
"yum update --security"
]
})),
cloudinit.GetConfigPartArgs(
content_type="text/x-shellscript",
filename="cloudinit/cloudinit.sh",
content=text_file.read(),
)])
export("resource_conf", resource_config.rendered)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment