# AWS上部署

默认安装Region:us-east-1

# 安装terraform

请参考 terraform install doc (opens new window)

# 配置AWS AccessKey Pair

export AWS_ACCESS_KEY_ID="anaccesskey"
export AWS_SECRET_ACCESS_KEY="asecretkey"
1
2

# 部署EMQX单节点

cd services/emqx
terraform init
terraform plan
terraform apply -auto-approve
1
2
3
4

# 部署EMQX集群

cd services/emqx_cluster
terraform init
terraform plan
terraform apply -auto-approve -var="ee_lic=${ee_lic}" -var="region=${region}"
1
2
3
4

Note: 如果部署企业版你需要申请一个license

如果apply成功,将输出:

Outputs:

emqx_cluster_address = "${prefix}.elb.${region}.amazonaws.com"
1
2
3

如果你想绑定一个域名,你需要配置CNAME

你能访问不同的服务通过不同的端口

Dashboard: ${prefix}.elb.${region}.amazonaws.com:18083
MQTT: ${prefix}.elb.${region}.amazonaws.com:1883
MQTTS: ${prefix}.elb.${region}.amazonaws.com:8883
WS: ${prefix}.elb.${region}.amazonaws.com:8083
WSS: ${prefix}.elb.${region}.amazonaws.com:8084
1
2
3
4
5

# 销毁

terraform destroy -auto-approve
1

Note: 由于节点用的是ubuntu 20.04,所以你需要指定相应操作系统的EMQX安装包