Amazon EC2
aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamlInstalls PostgreSQL database with optimized configuration
#cloud-config
package_update: true
package_upgrade: true
packages:
- postgresql
- postgresql-contrib
- postgresql-client
write_files:
- path: /etc/postgresql/14/main/postgresql.conf
content: |
listen_addresses = 'localhost'
port = 5432
max_connections = 100
shared_buffers = 128MB
effective_cache_size = 4GB
maintenance_work_mem = 64MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
append: false
runcmd:
- systemctl enable postgresql
- systemctl start postgresql
# Create application database and user
- sudo -u postgres createdb appdb
- sudo -u postgres psql -c "CREATE USER appuser WITH PASSWORD 'SecurePassword123!';"
- sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE appdb TO appuser;"
- systemctl restart postgresqlaws 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