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
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