Skip to content

Commit

Permalink
Debug public ip issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhaley committed May 10, 2024
1 parent 87464b2 commit c3c9e79
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/alternat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"

terraws "github.com/gruntwork-io/terratest/modules/aws"
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/gruntwork-io/terratest/modules/retry"
"github.com/gruntwork-io/terratest/modules/ssh"
Expand Down Expand Up @@ -114,7 +115,7 @@ func TestAlternat(t *testing.T) {
awsKeyPair := test_structure.LoadEc2KeyPair(t, exampleFolder)

authorizeSshIngress(t, ec2Client, sgId)
ip, err := getNatInstancePublicIp(ec2Client)
ip, err := getNatInstancePublicIp(t, ec2Client)
require.NoError(t, err)

natInstance := ssh.Host{
Expand Down Expand Up @@ -239,7 +240,7 @@ func getRouteTables(t *testing.T, client *ec2.Client, vpcID string) ([]ec2types.
return result.RouteTables, nil
}

func getNatInstancePublicIp(ec2Client *ec2.Client) (string, error) {
func getNatInstancePublicIp(t *testing.T, ec2Client *ec2.Client) (string, error) {
namePrefix := "alternat-"
input := &ec2.DescribeInstancesInput{
Filters: []ec2types.Filter{
Expand All @@ -256,6 +257,10 @@ func getNatInstancePublicIp(ec2Client *ec2.Client) (string, error) {
if err != nil {
return "", err
}

logger := logger.Logger{}
logger.Logf(t, "Reservations: %v", result.Reservations)

ip := aws.ToString(result.Reservations[0].Instances[0].PublicIpAddress)
if ip == "" {
return "", fmt.Errorf("Public IP not found")
Expand Down

0 comments on commit c3c9e79

Please sign in to comment.