Skip to content

Instantly share code, notes, and snippets.

@moss2k13
Created February 14, 2023 13:53
Show Gist options
  • Save moss2k13/3f1ec9649c1a957c1521e89e01d96a4e to your computer and use it in GitHub Desktop.
Save moss2k13/3f1ec9649c1a957c1521e89e01d96a4e to your computer and use it in GitHub Desktop.
aws --profile temporary-user sts get-session-token &> get-session-token
docker run -it --rm --name packer -v $(pwd):/workspace -w /workspace -e PACKER_LOG=1 -e AWS_ACCESS_KEY_ID=$(cat get-session-token | jq -r .Credentials.AccessKeyId) -e AWS_SECRET_ACCESS_KEY=$(cat get-session-token | jq -r .Credentials.SecretAccessKey) -e AWS_SESSION_TOKEN=$(cat get-session-token | jq -r .Credentials.SessionToken) -e AWS_REGION=eu-central-1 hashicorp/packer:1.8.5 build -var AmazonOsReleaseLabel=2.0.20221210.1 -var prefix=my-dev -var packerPath=/tmp/downloads -debug custom-emr-ami.json
2023/02/14 11:54:45 [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:45 [TRACE] discovering plugins in /bin
2023/02/14 11:54:45 [TRACE] discovering plugins in /root/.config/packer/plugins
2023/02/14 11:54:45 [TRACE] discovering plugins in .
2023/02/14 11:54:45 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:45 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:45 [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:45 [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:45 [TRACE] Starting internal plugin packer-builder-amazon-ebs
2023/02/14 11:54:45 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-builder-amazon-ebs"}
2023/02/14 11:54:45 Waiting for RPC address for: /bin/packer
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: args: []string{"packer-builder-amazon-ebs"}
2023/02/14 11:54:45 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin3174141168
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: Plugin address: unix /tmp/packer-plugin3174141168
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: Waiting for connection...
2023/02/14 11:54:45 packer-builder-amazon-ebs plugin: Serving a plugin connection...
2023/02/14 11:54:45 [TRACE] Starting internal plugin packer-provisioner-file
2023/02/14 11:54:45 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-file"}
2023/02/14 11:54:45 Waiting for RPC address for: /bin/packer
2023/02/14 11:54:46 packer-provisioner-file plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:46 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:46 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-file plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:46 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2023/02/14 11:54:46 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin3245800235
2023/02/14 11:54:46 packer-provisioner-file plugin: Waiting for connection...
2023/02/14 11:54:46 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin3245800235
2023/02/14 11:54:46 packer-provisioner-file plugin: Serving a plugin connection...
2023/02/14 11:54:46 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 11:54:46 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 11:54:46 Waiting for RPC address for: /bin/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 11:54:46 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin317282169
2023/02/14 11:54:46 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 11:54:46 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin317282169
2023/02/14 11:54:46 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 11:54:46 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 11:54:46 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 11:54:46 Waiting for RPC address for: /bin/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 11:54:46 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin3005042622
2023/02/14 11:54:46 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 11:54:46 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin3005042622
2023/02/14 11:54:46 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 11:54:46 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 11:54:46 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 11:54:46 Waiting for RPC address for: /bin/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 11:54:46 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 11:54:46 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 11:54:46 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin199153691
2023/02/14 11:54:46 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin199153691
2023/02/14 11:54:46 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 11:54:46 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 11:54:46 Preparing build: custom-emr-ami
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: [INFO] (aws): No AWS timeout and polling overrides have been set. Packer will default to waiter-specific delays and timeouts. If you would like to customize the length of time between retries and max number of retries you may do so by setting the environment variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS or the configuration options aws_polling_delay_seconds and aws_polling_max_attempts to your desired values.
2023/02/14 11:54:46 Build debug mode: true
2023/02/14 11:54:46 Force build: false
2023/02/14 11:54:46 On error:
2023/02/14 11:54:46 Debug enabled, so waiting for build to finish: custom-emr-ami
Debug mode enabled. Builds will not be parallelized.
2023/02/14 11:54:46 Starting build run: custom-emr-ami
2023/02/14 11:54:46 Running builder: amazon-ebs
2023/02/14 11:54:46 [INFO] (telemetry) Starting builder custom-emr-ami
custom-emr-ami: output will be in this color.
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: [INFO] AWS Auth provider used: "StaticProvider"
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: [INFO] Attempting to AssumeRole arn:aws:iam::063325037460:role/packer-test-role (SessionName: "packerwithoutconditions", ExternalId: "")
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] DEBUG: Request sts/AssumeRole Details:
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: ---[ REQUEST POST-SIGN ]-----------------------------
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: POST / HTTP/1.1
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Host: sts.amazonaws.com
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: User-Agent: aws-sdk-go/1.44.110 (go1.18.9; linux; amd64)
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Content-Length: 248
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Authorization: AWS4-HMAC-SHA256 Credential=<sensitive>/20230214/us-east-1/sts/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-security-token, Signature=0b7001716c65e7b42a4c11032c83b944db3d05072c2b4cae19c7db47f0df5261
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Content-Type: application/x-www-form-urlencoded; charset=utf-8
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: X-Amz-Date: 20230214T115446Z
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: X-Amz-Security-Token: <sensitive>
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Accept-Encoding: gzip
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin:
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: Action=AssumeRole&DurationSeconds=900&RoleArn=arn%3Aaws%3Aiam%3A%3A063325037460%3Arole%2Fpacker-test-role&RoleSessionName=packerwithoutconditions&Tags.member.1.Key=team&Tags.member.1.Value=MYTEAM&TransitiveTagKeys.member.1=team&Version=2011-06-15
2023/02/14 11:54:46 packer-builder-amazon-ebs plugin: -----------------------------------------------------
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] DEBUG: Response sts/AssumeRole Details:
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: ---[ RESPONSE ]--------------------------------------
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: HTTP/1.1 200 OK
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: Connection: close
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: Content-Length: 1160
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: Content-Type: text/xml
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: Date: Tue, 14 Feb 2023 11:54:47 GMT
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: X-Amzn-Requestid: 3ab66272-a5be-41f3-ae11-b6090e682f09
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin:
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin:
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: -----------------------------------------------------
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] <AssumeRoleResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <AssumeRoleResult>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <AssumedRoleUser>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <AssumedRoleId>AROAQ5PTXMOKNYTYDEY4L:packerwithoutconditions</AssumedRoleId>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <Arn>arn:aws:sts::063325037460:assumed-role/packer-test-role/packerwithoutconditions</Arn>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: </AssumedRoleUser>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <Credentials>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <AccessKeyId>ASIAQ5PTXMOKCFCEFF53</AccessKeyId>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <SecretAccessKey>X</SecretAccessKey>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <SessionToken>X</SessionToken>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <Expiration>2023-02-14T12:09:47Z</Expiration>
==> custom-emr-ami: Prevalidating any provided VPC information
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: </Credentials>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <PackedPolicySize>3</PackedPolicySize>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: </AssumeRoleResult>
==> custom-emr-ami: Prevalidating AMI Name: my-dev-build
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <ResponseMetadata>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: <RequestId>3ab66272-a5be-41f3-ae11-b6090e682f09</RequestId>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: </ResponseMetadata>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: </AssumeRoleResponse>
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: Found region eu-central-1
2023/02/14 11:54:47 packer-builder-amazon-ebs plugin: [INFO] AWS Auth provider used: "AssumeRoleProvider"
==> custom-emr-ami: Pausing after run of step 'StepPreValidate'. Press enter to continue.
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Using AMI Filters {
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Filters: [{
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Name: "root-device-type",
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Values: ["ebs"]
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: },{
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Name: "virtualization-type",
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Values: ["hvm"]
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: },{
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Name: "name",
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Values: ["amzn2-ami-hvm-2.0.20221210.1-x86_64-gp2"]
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: }],
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: Owners: ["137112412989"]
2023/02/14 11:54:51 packer-builder-amazon-ebs plugin: }
custom-emr-ami: Found Image ID: ami-04a2b113b98bfa0e8
==> custom-emr-ami: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> custom-emr-ami: Pausing after run of step 'StepNetworkInfo'. Press enter to continue.
==> custom-emr-ami: Creating temporary keypair: packer_63eb7686-5733-f65f-3bcf-6c77be22b176
custom-emr-ami: Saving key for debug purposes: ec2_custom-emr-ami.pem
==> custom-emr-ami: Pausing after run of step 'StepKeyPair'. Press enter to continue.
==> custom-emr-ami: Creating temporary security group for this instance: packer_63eb768f-5f2e-0847-4976-965febb3a523
2023/02/14 11:54:56 packer-builder-amazon-ebs plugin: [DEBUG] Waiting for temporary security group: sg-044d409a134c94610
2023/02/14 11:54:56 packer-builder-amazon-ebs plugin: [DEBUG] Found security group sg-044d409a134c94610
==> custom-emr-ami: Checking current host's public IP...
==> custom-emr-ami: Current host's public IP: 5.173.153.43
==> custom-emr-ami: Authorizing access to port 22 from [5.173.153.43/32] in the temporary security groups...
==> custom-emr-ami: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
==> custom-emr-ami: Pausing after run of step 'StepIamInstanceProfile'. Press enter to continue.
==> custom-emr-ami: Pausing after run of step 'StepCleanupVolumes'. Press enter to continue.
==> custom-emr-ami: Launching a source AWS instance...
custom-emr-ami: Adding tag: "team": "MYTEAM"
custom-emr-ami: Adding tag: "team": "MYTEAM"
custom-emr-ami: Instance ID: i-0feee96ae920351d6
==> custom-emr-ami: Waiting for instance (i-0feee96ae920351d6) to become ready...
2023/02/14 11:55:06 packer-provisioner-file plugin: Received interrupt signal (count: 1). Ignoring.
2023/02/14 11:55:06 Cancelling builder after context cancellation context canceled
Cancelling build after receiving interrupt
2023/02/14 11:55:06 packer-provisioner-shell plugin: Received interrupt signal (count: 1). Ignoring.
2023/02/14 11:55:06 packer-provisioner-shell plugin: Received interrupt signal (count: 1). Ignoring.
2023/02/14 11:55:06 packer-provisioner-shell plugin: Received interrupt signal (count: 1). Ignoring.
2023/02/14 11:55:06 packer-builder-amazon-ebs plugin: Received interrupt signal (count: 1). Ignoring.
==> custom-emr-ami: caused by: context canceled
==> custom-emr-ami: Error waiting for instance (i-0feee96ae920351d6) to become ready: RequestCanceled: waiter context canceled
==> custom-emr-ami: caused by: context canceled
==> custom-emr-ami: Terminating the source AWS instance...
==> custom-emr-ami: Pausing before cleanup of step 'StepCleanupVolumes'. Press enter to continue.
==> custom-emr-ami: No volumes to clean up, skipping
==> custom-emr-ami: Pausing before cleanup of step 'StepIamInstanceProfile'. Press enter to continue.
==> custom-emr-ami: Pausing before cleanup of step 'StepSecurityGroup'. Press enter to continue.
==> custom-emr-ami: Deleting temporary security group...
==> custom-emr-ami: Pausing before cleanup of step 'StepKeyPair'. Press enter to continue.
==> custom-emr-ami: Deleting temporary keypair...
==> custom-emr-ami: Pausing before cleanup of step 'StepNetworkInfo'. Press enter to continue. 2023/02/14 11:55:56 packer-builder-amazon-ebs plugin: Error asking for input: connection is shut down
2023/02/14 11:55:56 packer-builder-amazon-ebs plugin: Error asking for input: connection is shut down
2023/02/14 11:55:56 packer-builder-amazon-ebs plugin: Error asking for input: connection is shut down
2023/02/14 11:55:56 [INFO] (telemetry) ending custom-emr-ami
==> custom-emr-ami: Pausing before cleanup of step 'StepSourceAMIInfo'. Press enter to continue.
==> custom-emr-ami: Pausing before cleanup of step 'StepPreValidate'. Press enter to continue.
caused by: context canceled
2023/02/14 11:55:58 Waiting on builds to complete...
Build 'custom-emr-ami' errored after 1 minute 10 seconds: Error waiting for instance (i-0feee96ae920351d6) to become ready: RequestCanceled: waiter context canceled
==> Wait completed after 1 minute 12 seconds
caused by: context canceled
2023/02/14 11:55:58 [INFO] (telemetry) Finalizing.
==> Wait completed after 1 minute 12 seconds
Cleanly cancelled builds after being interrupted.
2023/02/14 11:56:00 [WARN] (telemetry) Error finalizing report. This is safe to ignore. Post "https://checkpoint-api.hashicorp.com/v1/telemetry/packer": context deadline exceeded
2023/02/14 11:56:00 waiting for all plugin processes to complete...
2023/02/14 11:56:00 /bin/packer: plugin process exited
2023/02/14 11:56:00 /bin/packer: plugin process exited
2023/02/14 11:56:00 /bin/packer: plugin process exited
2023/02/14 11:56:00 /bin/packer: plugin process exited
2023/02/14 11:56:00 /bin/packer: plugin process exited
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment