Skip to content

Instantly share code, notes, and snippets.

@moss2k13
Created February 14, 2023 13:56
Show Gist options
  • Save moss2k13/01e9109fc5ef665bb0b0de6181eac08a to your computer and use it in GitHub Desktop.
Save moss2k13/01e9109fc5ef665bb0b0de6181eac08a to your computer and use it in GitHub Desktop.
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 12:05:44 [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 [TRACE] discovering plugins in /bin
2023/02/14 12:05:44 [TRACE] discovering plugins in /root/.config/packer/plugins
2023/02/14 12:05:44 [TRACE] discovering plugins in .
2023/02/14 12:05:44 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 [TRACE] Starting internal plugin packer-builder-amazon-ebs
2023/02/14 12:05:44 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-builder-amazon-ebs"}
2023/02/14 12:05:44 Waiting for RPC address for: /bin/packer
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: args: []string{"packer-builder-amazon-ebs"}
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Plugin address: unix /tmp/packer-plugin921051344
2023/02/14 12:05:44 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin921051344
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Waiting for connection...
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Serving a plugin connection...
2023/02/14 12:05:44 [TRACE] Starting internal plugin packer-provisioner-file
2023/02/14 12:05:44 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-file"}
2023/02/14 12:05:44 Waiting for RPC address for: /bin/packer
2023/02/14 12:05:44 packer-provisioner-file plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-file plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2023/02/14 12:05:44 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin1188760176
2023/02/14 12:05:44 packer-provisioner-file plugin: Waiting for connection...
2023/02/14 12:05:44 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin1188760176
2023/02/14 12:05:44 packer-provisioner-file plugin: Serving a plugin connection...
2023/02/14 12:05:44 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 12:05:44 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 12:05:44 Waiting for RPC address for: /bin/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 12:05:44 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin114916938
2023/02/14 12:05:44 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 12:05:44 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin114916938
2023/02/14 12:05:44 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 12:05:44 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 12:05:44 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 12:05:44 Waiting for RPC address for: /bin/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 12:05:44 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin367136357
2023/02/14 12:05:44 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 12:05:44 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin367136357
2023/02/14 12:05:44 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 12:05:44 [TRACE] Starting internal plugin packer-provisioner-shell
2023/02/14 12:05:44 Starting plugin: /bin/packer []string{"/bin/packer", "plugin", "packer-provisioner-shell"}
2023/02/14 12:05:44 Waiting for RPC address for: /bin/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.5 [go1.18.9 linux amd64]
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/02/14 12:05:44 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/02/14 12:05:44 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2023/02/14 12:05:44 Received unix RPC address for /bin/packer: addr is /tmp/packer-plugin3330476672
2023/02/14 12:05:44 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin3330476672
2023/02/14 12:05:44 packer-provisioner-shell plugin: Waiting for connection...
2023/02/14 12:05:44 packer-provisioner-shell plugin: Serving a plugin connection...
2023/02/14 12:05:44 Preparing build: custom-emr-ami
2023/02/14 12:05:44 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 12:05:44 Build debug mode: true
2023/02/14 12:05:44 Force build: false
2023/02/14 12:05:44 On error:
2023/02/14 12:05:44 Debug enabled, so waiting for build to finish: custom-emr-ami
2023/02/14 12:05:44 Starting build run: custom-emr-ami
Debug mode enabled. Builds will not be parallelized.
2023/02/14 12:05:44 Running builder: amazon-ebs
2023/02/14 12:05:44 [INFO] (telemetry) Starting builder custom-emr-ami
custom-emr-ami: output will be in this color.
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] AWS Auth provider used: "StaticProvider"
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [INFO] Attempting to AssumeRole arn:aws:iam::063325037460:role/packer-test-role (SessionName: "packerwithconditions", ExternalId: "")
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] DEBUG: Request sts/AssumeRole Details:
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: ---[ REQUEST POST-SIGN ]-----------------------------
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: POST / HTTP/1.1
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Host: sts.amazonaws.com
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: User-Agent: aws-sdk-go/1.44.110 (go1.18.9; linux; amd64)
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Content-Length: 245
2023/02/14 12:05:44 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=5f5dccace8cc93426296d08994f73cf979778399fb1681683555634933d3b81f
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Content-Type: application/x-www-form-urlencoded; charset=utf-8
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: X-Amz-Date: 20230214T120544Z
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: X-Amz-Security-Token: <sensitive>
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Accept-Encoding: gzip
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin:
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: Action=AssumeRole&DurationSeconds=900&RoleArn=arn%3Aaws%3Aiam%3A%3A063325037460%3Arole%2Fpacker-test-role&RoleSessionName=packerwithconditions&Tags.member.1.Key=team&Tags.member.1.Value=MYTEAM&TransitiveTagKeys.member.1=team&Version=2011-06-15
2023/02/14 12:05:44 packer-builder-amazon-ebs plugin: -----------------------------------------------------
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] DEBUG: Response sts/AssumeRole Details:
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: ---[ RESPONSE ]--------------------------------------
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: HTTP/1.1 200 OK
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: Connection: close
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: Content-Length: 1150
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: Content-Type: text/xml
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: Date: Tue, 14 Feb 2023 12:05:45 GMT
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: X-Amzn-Requestid: ab083e6a-0c98-4f3e-a77b-42032d4eae14
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin:
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin:
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: -----------------------------------------------------
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: [DEBUG] [aws-sdk-go] <AssumeRoleResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <AssumeRoleResult>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <AssumedRoleUser>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <AssumedRoleId>AROAQ5PTXMOKNYTYDEY4L:packerwithconditions</AssumedRoleId>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <Arn>arn:aws:sts::063325037460:assumed-role/packer-test-role/packerwithconditions</Arn>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: </AssumedRoleUser>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <Credentials>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <AccessKeyId>ASIAQ5PTXMOKLK65ESJ5</AccessKeyId>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <SecretAccessKey>X</SecretAccessKey>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <SessionToken>X</SessionToken>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <Expiration>2023-02-14T12:20:45Z</Expiration>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: </Credentials>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <PackedPolicySize>3</PackedPolicySize>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: </AssumeRoleResult>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <ResponseMetadata>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: <RequestId>ab083e6a-0c98-4f3e-a77b-42032d4eae14</RequestId>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: </ResponseMetadata>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: </AssumeRoleResponse>
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: Found region eu-central-1
2023/02/14 12:05:45 packer-builder-amazon-ebs plugin: [INFO] AWS Auth provider used: "AssumeRoleProvider"
==> custom-emr-ami: Prevalidating any provided VPC information
==> custom-emr-ami: Prevalidating AMI Name: my-dev-build
==> custom-emr-ami: status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
2023/02/14 12:05:46 [INFO] (telemetry) ending custom-emr-ami
==> custom-emr-ami: Error querying AMI: UnauthorizedOperation: You are not authorized to perform this operation.
status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
2023/02/14 12:05:46 Waiting on builds to complete...
==> Wait completed after 1 second 91 milliseconds
2023/02/14 12:05:46 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2023/02/14 12:05:46 machine readable: custom-emr-ami,error []string{"Error querying AMI: UnauthorizedOperation: You are not authorized to perform this operation.\n\tstatus code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244"}
status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
==> Builds finished but no artifacts were created.
==> custom-emr-ami: status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
2023/02/14 12:05:46 [INFO] (telemetry) Finalizing.
Build 'custom-emr-ami' errored after 1 second 91 milliseconds: Error querying AMI: UnauthorizedOperation: You are not authorized to perform this operation.
status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
==> Wait completed after 1 second 91 milliseconds
==> Some builds didn't complete successfully and had errors:
--> custom-emr-ami: Error querying AMI: UnauthorizedOperation: You are not authorized to perform this operation.
status code: 403, request id: 09c9359f-d5a0-4b3e-94c7-bacae988c244
==> Builds finished but no artifacts were created.
2023/02/14 12:05:46 waiting for all plugin processes to complete...
2023/02/14 12:05:46 /bin/packer: plugin process exited
2023/02/14 12:05:46 /bin/packer: plugin process exited
2023/02/14 12:05:46 /bin/packer: plugin process exited
2023/02/14 12:05:46 /bin/packer: plugin process exited
2023/02/14 12:05:46 /bin/packer: plugin process exited
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment