I’m more curious why you want to. I don’t believe it’s possible with packer, packer internally knows the IP address of the created instance so it does need to be specified.
> On 4 Feb 2021, at 21:48, venkat G <[email protected]> wrote: > > > I want packer to spin up Ec2 with status IP . > > Right now it is creating Ec2 with a random private ip each time when I run > the packer. > > Thanks for your response. > >> On Thu, Feb 4, 2021 at 1:03 PM Alvaro Miranda Aguilera <[email protected]> >> wrote: >> hi >> >> packer on aws will create an instance, and packer will know how to ssh to >> that instance. >> >> is not clear what you want to do. >> >> you are having an existing VM with a known IP you want to connect and run >> provisioners? >> >> >> or >> >> >> you want packer to build an ec2 instance with a fixed IP? >> where you read in the documentation how to setup a fixed ip in packer for >> AWS instance ? >> >> alvaro >> >>> On Thu, Feb 4, 2021 at 6:27 PM venkat G <[email protected]> wrote: >>> I need to assign fixed or static ip address to the EC2. >>> >>> The below code is not working. >>> >>> "instance_type": "t2.micro", >>> "ami_name": "Prod-CIS-Latest-AMZN-{{isotime \"02-Jan-06 03_04_05\"}}", >>> "ami_description": "Amazon Linux CIS with Cloudwatch Logs agent", >>> "associate_public_ip_address": "true", >>> "vpc_id": "***********", >>> "subnet_id": "*************", >>> "security_group_id": "*********", >>> "communicator": "ssh", >>> "ssh_username": "ec2-user", >>> "ssh_host": " 10.112.16.204 ", >>> "ssh_interface": "private_ip" >>> >>> [Container] 2021/02/04 17:17:38 Running command packer build -color=false >>> packer_cis.json | tee build.log >>> ==> AWS AMI Builder - CIS: Prevalidating any provided VPC information >>> ==> AWS AMI Builder - CIS: Prevalidating AMI Name: >>> Prod-CIS-Latest-AMZN-04-Feb-21 05_17_38 >>> AWS AMI Builder - CIS: Found Image ID: ami-085e8e97986e5710f >>> ==> AWS AMI Builder - CIS: Creating temporary keypair: >>> packer_601c2c32-4150-3553-fb9d-b351b5a2b137 >>> ==> AWS AMI Builder - CIS: Launching a source AWS instance... >>> ==> AWS AMI Builder - CIS: Adding tags to source instance >>> AWS AMI Builder - CIS: Adding tag: "Name": "Packer Builder" >>> AWS AMI Builder - CIS: Instance ID: i-0ea3f33db710bd78a >>> ==> AWS AMI Builder - CIS: Waiting for instance (i-0ea3f33db710bd78a) to >>> become ready... >>> ==> AWS AMI Builder - CIS: Using ssh communicator to connect: 10.112.16.204 >>> ==> AWS AMI Builder - CIS: Waiting for SSH to become available... >>> ==> AWS AMI Builder - CIS: Timeout waiting for SSH. >>> ==> AWS AMI Builder - CIS: Terminating the source AWS instance... >>> ==> AWS AMI Builder - CIS: Cleaning up any extra volumes... >>> ==> AWS AMI Builder - CIS: No volumes to clean up, skipping >>> ==> AWS AMI Builder - CIS: Deleting temporary keypair... >>> Build 'AWS AMI Builder - CIS' errored after 6 minutes 34 seconds: Timeout >>> waiting for SSH. >>> [Container] 2021/02/04 17:17:38 Running command packer build -color=false >>> packer_cis.json | tee build.log >>> 32 >>> ==> AWS AMI Builder - CIS: Prevalidating any provided VPC information >>> 33 >>> ==> AWS AMI Builder - CIS: Prevalidating AMI Name: >>> Prod-CIS-Latest-AMZN-04-Feb-21 05_17_38 >>> 34 >>> AWS AMI Builder - CIS: Found Image ID: ami-085e8e97986e5710f >>> 35 >>> ==> AWS AMI Builder - CIS: Creating temporary keypair: >>> packer_601c2c32-4150-3553-fb9d-b351b5a2b137 >>> 36 >>> ==> AWS AMI Builder - CIS: Launching a source AWS instance... >>> 37 >>> ==> AWS AMI Builder - CIS: Adding tags to source instance >>> 38 >>> AWS AMI Builder - CIS: Adding tag: "Name": "Packer Builder" >>> 39 >>> AWS AMI Builder - CIS: Instance ID: i-0ea3f33db710bd78a >>> 40 >>> ==> AWS AMI Builder - CIS: Waiting for instance (i-0ea3f33db710bd78a) to >>> become ready... >>> 41 >>> ==> AWS AMI Builder - CIS: Using ssh communicator to connect: 10.112.16.204 >>> 42 >>> ==> AWS AMI Builder - CIS: Waiting for SSH to become available... >>> 43 >>> ==> AWS AMI Builder - CIS: Timeout waiting for SSH. >>> 44 >>> ==> AWS AMI Builder - CIS: Terminating the source AWS instance... >>> 45 >>> ==> AWS AMI Builder - CIS: Cleaning up any extra volumes... >>> 46 >>> ==> AWS AMI Builder - CIS: No volumes to clean up, skipping >>> 47 >>> ==> AWS AMI Builder - CIS: Deleting temporary keypair... >>> 48 >>> Build 'AWS AMI Builder - CIS' errored after 6 minutes 34 seconds: Timeout >>> waiting for SSH. >>> -- >>> This mailing list is governed under the HashiCorp Community Guidelines - >>> https://www.hashicorp.com/community-guidelines.html. Behavior in violation >>> of those guidelines may result in your removal from this mailing list. >>> >>> GitHub Issues: https://github.com/hashicorp/packer/issues >>> IRC: #packer-tool on Freenode >>> --- >>> You received this message because you are subscribed to the Google Groups >>> "Packer" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/packer-tool/4b558793-0ebd-4c3f-ac95-52a3964b507fn%40googlegroups.com. >> >> >> -- >> Alvaro >> >> -- >> This mailing list is governed under the HashiCorp Community Guidelines - >> https://www.hashicorp.com/community-guidelines.html. Behavior in violation >> of those guidelines may result in your removal from this mailing list. >> >> GitHub Issues: https://github.com/hashicorp/packer/issues >> IRC: #packer-tool on Freenode >> --- >> You received this message because you are subscribed to the Google Groups >> "Packer" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/packer-tool/CAHqq0exzFGQ4tY27fLVaj1_koUqcTqCAq_0EWCi7McXSXmHXEg%40mail.gmail.com. > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html. Behavior in violation of > those guidelines may result in your removal from this mailing list. > > GitHub Issues: https://github.com/hashicorp/packer/issues > IRC: #packer-tool on Freenode > --- > You received this message because you are subscribed to the Google Groups > "Packer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/packer-tool/CAPr%3DmyFNvNiYButcWevCG38TPprQhyYPYF8b9dBh1wdaQ6jdgg%40mail.gmail.com. -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/hashicorp/packer/issues IRC: #packer-tool on Freenode --- You received this message because you are subscribed to the Google Groups "Packer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/C3AB6A3D-CE30-451E-A11C-2F44B854D5B3%40irrelevant.org.
