amazon web services - AWS Spot Instances created with Terraform Spot-fleet request does not return public_ip address -
i provisioning aws spot-fleet using terraform.
the spot-fleet gets provisioned issue comes when try use ssh connect instance can run node.js app on (pre-installed on ami). not able retrieve public_ip address of instances has been provisioned.
my request looks this:
main.tf
provider "aws" { access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "${var.aws_region}" } resource "aws_spot_fleet_request" "spot_fleet" { iam_fleet_role = "${var.iam_fleet_role}" spot_price = "${var.spot_price}" allocation_strategy = "${var.allocation_strategy}" target_capacity = "${var.target_capacity}" terminate_instances_with_expiration = "${var.terminate_instances_with_expiration}" valid_until = "${var.valid_until}" wait_for_fulfillment = "${var.wait_for_fulfillment}" launch_specification { instance_type = "${var.instance_type}" key_name = "${var.key_name}" ami = "${var.ami}" vpc_security_group_ids = ["${var.security_group_id}"] root_block_device { volume_size = "${var.volume_size}" volume_type = "${var.volume_type}" } } provisioner "remote-exec" { inline = [ "cd my-app", "npm install", "npm start", ] connection { host = "${self.public_ip}" type = "ssh" user = "ubuntu" private_key = "${file("my-secret.pem")}" timeout = "2m" agent = false } } } this error get:
error applying plan: 1 error(s) occurred: * aws_spot_fleet_request.spot_fleet: 1 error(s) occurred: * resource 'aws_spot_fleet_request.spot_fleet' not have attribute 'public_ip' variable 'aws_spot_fleet_request.spot_fleet.0.public_ip' the provisioned spot instances such have public ip address , able see in aws console.
i able ssh instance using terminal.
Comments
Post a Comment