Amazon EC2
aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamlInstalls and configures Elasticsearch for full-text search
#cloud-config
package_update: true
package_upgrade: true
packages:
- openjdk-11-jdk
- wget
- gnupg
- apt-transport-https
write_files:
- path: /etc/elasticsearch/elasticsearch.yml
content: |
cluster.name: my-application
node.name: node-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: localhost
http.port: 9200
discovery.type: single-node
xpack.security.enabled: false
append: false
runcmd:
# Add Elasticsearch repository
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
- echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-7.x.list
# Install Elasticsearch
- apt-get update
- apt-get install -y elasticsearch
# Configure JVM heap size
- sed -i 's/-Xms1g/-Xms512m/g' /etc/elasticsearch/jvm.options
- sed -i 's/-Xmx1g/-Xmx512m/g' /etc/elasticsearch/jvm.options
# Start Elasticsearch
- systemctl enable elasticsearch
- systemctl start elasticsearch
# Wait for startup and test
- sleep 30
- curl -X GET "localhost:9200/"aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamldoctl compute droplet create
--image ubuntu-22-04-x64
--size s-1vcpu-1gb
--user-data-file script.yaml
my-dropletgcloud compute instances create
my-instance
--metadata-from-file
user-data=script.yaml