{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/101","repository_url":"https://api.github.com/repos/aws/aws-codebuild-docker-images","labels_url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/101/comments","events_url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/101/events","html_url":"https://github.com/aws/aws-codebuild-docker-images/issues/101","id":345406550,"node_id":"MDU6SXNzdWUzNDU0MDY1NTA=","number":101,"title":"local builds has problem with ec2 parameter store in buildspec file","user":{"login":"namredips","id":765093,"node_id":"MDQ6VXNlcjc2NTA5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/765093?v=4","gravatar_id":"","url":"https://api.github.com/users/namredips","html_url":"https://github.com/namredips","followers_url":"https://api.github.com/users/namredips/followers","following_url":"https://api.github.com/users/namredips/following{/other_user}","gists_url":"https://api.github.com/users/namredips/gists{/gist_id}","starred_url":"https://api.github.com/users/namredips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namredips/subscriptions","organizations_url":"https://api.github.com/users/namredips/orgs","repos_url":"https://api.github.com/users/namredips/repos","events_url":"https://api.github.com/users/namredips/events{/privacy}","received_events_url":"https://api.github.com/users/namredips/received_events","type":"User","site_admin":false},"labels":[{"id":933881374,"node_id":"MDU6TGFiZWw5MzM4ODEzNzQ=","url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/labels/CodeBuild-local","name":"CodeBuild-local","color":"a0f7db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-28T01:36:57Z","updated_at":"2018-08-21T20:01:19Z","closed_at":null,"author_association":"NONE","body":"using parameters in buildspec doesn't seem to work with local builds. Given the following buildspec file:\r\n\r\n`version: 0.2\r\n\r\nenv:\r\n  parameter-store:\r\n    RELEASE: \"/ReconMVS/Release/Version\"\r\n\r\nphases:\r\n  install:\r\n    commands:\r\n      - aws configure list\r\n      - aws configure set region us-east-1\r\n      - aws ssm get-parameters --names \"/ReconMVS/Release/Version\"\r\n      - ./build.sh --install\r\n\r\n  pre_build:\r\n    commands:\r\n      - ./build.sh --pre_build\r\n\r\n  build:\r\n    commands:\r\n      - ./build.sh --build\r\n\r\n  post_build:\r\n    commands:\r\n      - ./build.sh --deploy`\r\n\r\nwhen I execute: \r\n`codebuild_build.sh -i aws/codebuild/python:3.6.5 -a artifacts -c`\r\n\r\nget the output of:\r\n\r\n`Build Command:\r\n\r\ndocker run -it -v /var/run/docker.sock:/var/run/docker.sock -e \"IMAGE_NAME=aws/codebuild/python:3.6.5\" -e \"ARTIFACTS=/home/ec2-user/environment/rpp-lib/artifacts\" -e \"SOURCE=/home/ec2-user/environment/rpp-lib\" -e \"AWS_CONFIGURATION=/home/ec2-user/.aws\" -e \"AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon\" -e \"AWS_REGION=us-east-1\" -e \"AWS_PATH=/opt/aws\" -e \"AWS_AUTO_SCALING_HOME=/opt/aws/apitools/as\" -e \"AWS_ELB_HOME=/opt/aws/apitools/elb\" amazon/aws-codebuild-local:latest\r\n\r\nRemoving agentresources_build_1 ... done\r\nRemoving agentresources_agent_1 ... done\r\nRemoving network agentresources_default\r\nRemoving volume agentresources_user_volume\r\nRemoving volume agentresources_source_volume\r\nCreating network \"agentresources_default\" with the default driver\r\nCreating volume \"agentresources_user_volume\" with local driver\r\nCreating volume \"agentresources_source_volume\" with local driver\r\nCreating agentresources_agent_1 ... \r\nCreating agentresources_agent_1 ... done\r\nCreating agentresources_build_1 ... \r\nCreating agentresources_build_1 ... done\r\nAttaching to agentresources_agent_1, agentresources_build_1\r\nagent_1  | [Container] 2018/07/28 01:24:40 Waiting for agent ping\r\nagent_1  | [Container] 2018/07/28 01:24:40 Waiting for DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:24:41 Phase is DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:24:41 CODEBUILD_SRC_DIR=/codebuild/output/src472955516/src\r\nagent_1  | [Container] 2018/07/28 01:24:41 YAML location is /codebuild/output/src472955516/src/buildspec.yml\r\nagent_1  | [Container] 2018/07/28 01:24:41 Processing environment variables\r\nagent_1  | [Container] 2018/07/28 01:24:41 Decrypting parameter store environment variables\r\nagent_1  | [Container] 2018/07/28 01:26:41 Phase complete: DOWNLOAD_SOURCE Success: false\r\nagent_1  | [Container] 2018/07/28 01:26:41 Phase context status code: Decrypted Variables Error Message: UnrecognizedClientException: The security token included in the request is invalid.\r\nagent_1  |      status code: 400, request id: 0a474c1a-36c9-4dfc-a39c-b72f5da9773b\r\nagent_1  | [Container] 2018/07/28 01:26:41 Runtime error (*awserr.requestError: UnrecognizedClientException: The security token included in the request is invalid.\r\nagent_1  |      status code: 400, request id: 0a474c1a-36c9-4dfc-a39c-b72f5da9773b)\r\nagentresources_build_1 exited with code 0\r\nagentresources_agent_1 exited with code 0`\r\n\r\nif I run the same command against buildspec without `parameter` section:\r\n\r\n`version: 0.2\r\n\r\nphases:\r\n  install:\r\n    commands:\r\n      - aws configure list\r\n      - aws configure set region us-east-1\r\n      - aws ssm get-parameters --names \"/ReconMVS/Release/Version\"\r\n      - ./build.sh --install\r\n\r\n  pre_build:\r\n    commands:\r\n      - ./build.sh --pre_build\r\n\r\n  build:\r\n    commands:\r\n      - ./build.sh --build\r\n\r\n  post_build:\r\n    commands:\r\n      - ./build.sh --deploy`\r\n\r\nI get the following: \r\n\r\n`Build Command:\r\n\r\ndocker run -it -v /var/run/docker.sock:/var/run/docker.sock -e \"IMAGE_NAME=aws/codebuild/python:3.6.5\" -e \"ARTIFACTS=/home/ec2-user/environment/rpp-lib/artifacts\" -e \"SOURCE=/home/ec2-user/environment/rpp-lib\" -e \"AWS_CONFIGURATION=/home/ec2-user/.aws\" -e \"AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon\" -e \"AWS_REGION=us-east-1\" -e \"AWS_PATH=/opt/aws\" -e \"AWS_AUTO_SCALING_HOME=/opt/aws/apitools/as\" -e \"AWS_ELB_HOME=/opt/aws/apitools/elb\" amazon/aws-codebuild-local:latest\r\n\r\nRemoving agentresources_build_1 ... done\r\nRemoving agentresources_agent_1 ... done\r\nRemoving network agentresources_default\r\nRemoving volume agentresources_user_volume\r\nRemoving volume agentresources_source_volume\r\nCreating network \"agentresources_default\" with the default driver\r\nCreating volume \"agentresources_user_volume\" with local driver\r\nCreating volume \"agentresources_source_volume\" with local driver\r\nCreating agentresources_agent_1 ...\r\nCreating agentresources_agent_1 ... done\r\nCreating agentresources_build_1 ...\r\nCreating agentresources_build_1 ... done\r\nAttaching to agentresources_agent_1, agentresources_build_1\r\nagent_1  | [Container] 2018/07/28 01:28:16 Waiting for agent ping\r\nagent_1  | [Container] 2018/07/28 01:28:16 Waiting for DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:28:16 Phase is DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:28:16 CODEBUILD_SRC_DIR=/codebuild/output/src870959505/src\r\nagent_1  | [Container] 2018/07/28 01:28:16 YAML location is /codebuild/output/src870959505/src/buildspec.yml\r\nagent_1  | [Container] 2018/07/28 01:28:16 Processing environment variables\r\nagent_1  | [Container] 2018/07/28 01:28:16 Moving to directory /codebuild/output/src870959505/src\r\nagent_1  | [Container] 2018/07/28 01:28:16 Registering with agent\r\nagent_1  | [Container] 2018/07/28 01:28:16 Phases found in YAML: 4\r\nagent_1  | [Container] 2018/07/28 01:28:16  BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:28:16  POST_BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:28:16  INSTALL: 4 commands\r\nagent_1  | [Container] 2018/07/28 01:28:16  PRE_BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:28:16 Phase complete: DOWNLOAD_SOURCE Success: true\r\nagent_1  | [Container] 2018/07/28 01:28:16 Phase context status code:  Message:\r\nagent_1  | [Container] 2018/07/28 01:28:16 Entering phase INSTALL\r\nagent_1  | [Container] 2018/07/28 01:28:16 Running command aws configure list\r\nagent_1  |       Name                    Value             Type    Location\r\nagent_1  |       ----                    -----             ----    --------\r\nagent_1  |    profile                <not set>             None    None\r\nagent_1  | access_key     ****************HGFJ shared-credentials-file\r\nagent_1  | secret_key     ****************nLR8 shared-credentials-file\r\nagent_1  |     region                us-east-1      config-file    ~/.aws/config\r\nagent_1  |\r\nagent_1  | [Container] 2018/07/28 01:28:18 Running command aws configure set region us-east-1\r\nagent_1  |\r\nagent_1  | [Container] 2018/07/28 01:28:18 Running command aws ssm get-parameters --names \"/ReconMVS/Release/Version\"\r\nagent_1  | {\r\nagent_1  |     \"Parameters\": [\r\nagent_1  |         {\r\nagent_1  |             \"Name\": \"/ReconMVS/Release/Version\",\r\nagent_1  |             \"Type\": \"String\",\r\nagent_1  |             \"Value\": \"reconmvs-224\",\r\nagent_1  |             \"Version\": 5,\r\nagent_1  |             \"LastModifiedDate\": 1531895628.923,\r\nagent_1  |             \"ARN\": \"arn:aws:ssm:us-east-1:423319072129:parameter/ReconMVS/Release/Version\"\r\nagent_1  |         }\r\nagent_1  |     ],\r\nagent_1  |     \"InvalidParameters\": []\r\nagent_1  | }\r\nagent_1  |\r\na`\r\n\r\nIf I run without `-c` and use the instance profile set on the aws cloud9 instance being used I get:\r\n\r\nversion: 0.2\r\n\r\nphases:\r\n  install:\r\n    commands:\r\n      - aws configure list\r\n      - aws configure set region us-east-1\r\n      - aws ssm get-parameters --names \"/ReconMVS/Release/Version\"\r\n      - ./build.sh --install\r\n\r\n  pre_build:\r\n    commands:\r\n      - ./build.sh --pre_build\r\n\r\n  build:\r\n    commands:\r\n      - ./build.sh --build\r\n\r\n  post_build:\r\n    commands:\r\n      - ./build.sh --deploy\r\nAdministrator:~/environment/rpp-lib (master) $ ./local_build.sh -i aws/codebuild/python:3.6.5 -a artifacts\r\nBuild Command:\r\n\r\ndocker run -it -v /var/run/docker.sock:/var/run/docker.sock -e \"IMAGE_NAME=aws/codebuild/python:3.6.5\" -e \"ARTIFACTS=/home/ec2-user/environment/rpp-lib/artifacts\" -e \"SOURCE=/home/ec2-user/environment/rpp-lib\" amazon/aws-codebuild-local:latest\r\n\r\nRemoving agentresources_build_1 ... done\r\nRemoving agentresources_agent_1 ... done\r\nRemoving network agentresources_default\r\nRemoving volume agentresources_user_volume\r\nRemoving volume agentresources_source_volume\r\nCreating network \"agentresources_default\" with the default driver\r\nCreating volume \"agentresources_user_volume\" with local driver\r\nCreating volume \"agentresources_source_volume\" with local driver\r\nCreating agentresources_agent_1 ... \r\nCreating agentresources_agent_1 ... done\r\nCreating agentresources_build_1 ... \r\nCreating agentresources_build_1 ... done\r\nAttaching to agentresources_agent_1, agentresources_build_1\r\nagent_1  | [Container] 2018/07/28 01:31:55 Waiting for agent ping\r\nagent_1  | [Container] 2018/07/28 01:31:55 Waiting for DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:31:55 Phase is DOWNLOAD_SOURCE\r\nagent_1  | [Container] 2018/07/28 01:31:55 CODEBUILD_SRC_DIR=/codebuild/output/src247163626/src\r\nagent_1  | [Container] 2018/07/28 01:31:55 YAML location is /codebuild/output/src247163626/src/buildspec.yml\r\nagent_1  | [Container] 2018/07/28 01:31:55 Processing environment variables\r\nagent_1  | [Container] 2018/07/28 01:31:55 Moving to directory /codebuild/output/src247163626/src\r\nagent_1  | [Container] 2018/07/28 01:31:55 Registering with agent\r\nagent_1  | [Container] 2018/07/28 01:31:55 Phases found in YAML: 4\r\nagent_1  | [Container] 2018/07/28 01:31:55  INSTALL: 4 commands\r\nagent_1  | [Container] 2018/07/28 01:31:55  PRE_BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:31:55  BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:31:55  POST_BUILD: 1 commands\r\nagent_1  | [Container] 2018/07/28 01:31:55 Phase complete: DOWNLOAD_SOURCE Success: true\r\nagent_1  | [Container] 2018/07/28 01:31:55 Phase context status code:  Message: \r\nagent_1  | [Container] 2018/07/28 01:31:55 Entering phase INSTALL\r\nagent_1  | [Container] 2018/07/28 01:31:55 Running command aws configure list\r\nagent_1  |       Name                    Value             Type    Location\r\nagent_1  |       ----                    -----             ----    --------\r\nagent_1  |    profile                <not set>             None    None\r\nagent_1  | access_key     ****************36UQ         iam-role    \r\nagent_1  | secret_key     ****************be/B         iam-role    \r\nagent_1  |     region                <not set>             None    None\r\nagent_1  | \r\nagent_1  | [Container] 2018/07/28 01:31:56 Running command aws configure set region us-east-1\r\nagent_1  | \r\nagent_1  | [Container] 2018/07/28 01:31:57 Running command aws ssm get-parameters --names \"/ReconMVS/Release/Version\"\r\nagent_1  | {\r\nagent_1  |     \"Parameters\": [\r\nagent_1  |         {\r\nagent_1  |             \"Name\": \"/ReconMVS/Release/Version\",\r\nagent_1  |             \"Type\": \"String\",\r\nagent_1  |             \"Value\": \"reconmvs-224\",\r\nagent_1  |             \"Version\": 5,\r\nagent_1  |             \"LastModifiedDate\": 1531895628.923,\r\nagent_1  |             \"ARN\": \"arn:aws:ssm:us-east-1:423319072129:parameter/ReconMVS/Release/Version\"\r\nagent_1  |         }\r\nagent_1  |     ],\r\nagent_1  |     \"InvalidParameters\": []\r\nagent_1  | }\r\n"},"comment":{"url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/comments/414802739","html_url":"https://github.com/aws/aws-codebuild-docker-images/issues/101#issuecomment-414802739","issue_url":"https://api.github.com/repos/aws/aws-codebuild-docker-images/issues/101","id":414802739,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDgwMjczOQ==","user":{"login":"subinataws","id":24447312,"node_id":"MDQ6VXNlcjI0NDQ3MzEy","avatar_url":"https://avatars2.githubusercontent.com/u/24447312?v=4","gravatar_id":"","url":"https://api.github.com/users/subinataws","html_url":"https://github.com/subinataws","followers_url":"https://api.github.com/users/subinataws/followers","following_url":"https://api.github.com/users/subinataws/following{/other_user}","gists_url":"https://api.github.com/users/subinataws/gists{/gist_id}","starred_url":"https://api.github.com/users/subinataws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subinataws/subscriptions","organizations_url":"https://api.github.com/users/subinataws/orgs","repos_url":"https://api.github.com/users/subinataws/repos","events_url":"https://api.github.com/users/subinataws/events{/privacy}","received_events_url":"https://api.github.com/users/subinataws/received_events","type":"User","site_admin":false},"created_at":"2018-08-21T20:01:19Z","updated_at":"2018-08-21T20:01:19Z","author_association":"CONTRIBUTOR","body":"Can you try running your local build as per instructions to pass the .aws directory? Details here: https://github.com/aws/aws-codebuild-docker-images/tree/master/local_builds#aws-codebuild-local-builds (use option -c)."}}
{"actor":{"display_login":"subinataws"}}