chadgeary / nifi

Deploy a secured, clustered, auto-scaling NiFi service in AWS.
48 stars 14 forks source link

How can I SSH to ELB Hostname? #2

Closed medined closed 4 years ago

medined commented 4 years ago

Hi. Thanks for letting this project into the public. In your readme, it says "ssh to ELB hostname" in order to find the keystore.pks12 file. How is that done?

I have run the project and the AWS resources have been created.

chadgeary commented 4 years ago

You're very welcome.

  1. Ensure you've set the ssh key and mgmt_cidr variables in tf-nifi.tfvars.

  2. Get the ELB hostname.

You can find the ELB hostname in the terraform.tfstate file, e.g.:

grep '"dns_name"' terraform.tfstate
            "dns_name": "chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com",

or via aws cli, e.g.:

aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[DNSName, LoadBalancerName]' --output text
chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com    chad-test-elb

and I've updated the git project with a terraform output that prints the ELB's DNS whenever terraform apply or terraform output is run, e.g.: After terraform apply:

terraform apply -var-file="tf-nifi.tfvars"
data.archive_file.tf-nifi-lambda-file-node-down: Refreshing state...
data.aws_iam_user.tf-nifi-kmsmanager: Refreshing state...
 ...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:
tf-nifi-elb-dnsname-output = chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com

or terraform output:

terraform output
tf-nifi-elb-dnsname-output = chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com
  1. Ensure there are healthy instances attached (e.g. NiFi is up and running)

via aws cli, e.g.:

aws elb describe-instance-health --load-balancer-name chad-test-elb
  1. Grab the file via SSH to the ELB hostname with the ubuntu user, e.g.:
# ssh
ssh ubuntu@chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com
# copy to ubuntu home and change permissions
sudo cp /opt/nifi-certificates/admin/keystore.pkcs12 ~/
sudo chown ubuntu ~/keystore.pkcs12
# exit to local machine
exit
# copy via scp from - keep in mind the ELB might connect SCP to another nifi machine (multiple tries may be needed!)
scp ubuntu@chad-dev-elb-1208700909.us-east-2.elb.amazonaws.com ~/keystore.pkcs12

I would suggest grabbing the file from S3 instead! :)