We are having projects created with aws codestar. these were working fine. but from today we are facing following issue:
Logs:
'Unable to upload artifact None referenced by CodeUri parameter of GetCompanyRecords resource. zip does not support timestamps before 1980'
Now when i removed aws-sdk module again it works fine. but when i add it again build fails. i am pretty much worried about this. Here is my lambda function.
GetCompanyRecords:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs6.10
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Timeout: 10
Events:
PostEvent:
Type: Api
Properties:
Path: /getCompanyRecords
Method: post
Here is pacakge.json
"dependencies": {
"aws-sdk": "^2.211.0",
"aws-serverless-express": "latest",
"body-parser": "^1.18.2",
"chai": "^4.1.2",
"chai-http": "^3.0.0",
"cors": "^2.8.4",
"country-list": "^1.1.0",
"express": "^4.16.2",
"mocha": "^5.0.0",
"promise": "^8.0.1",
"provinces": "^1.11.0",
"underscore": "^1.8.3",
"uuid": "^3.2.1"
}
Thanks in advance
+1
+1
+1 -- related: https://github.com/feross/ieee754/issues/17
I am facing this issue explicitly with 'aws-sdk'. When i add it in node modules i get the exception but when i remove it's all fine.
@zimny , @abajowski , @gbegher at the moment following patch fixed my issue:
I added following lines to buildspec.yml after 'npm install'
But i want aws to fix to this issue. I am really disappointed aws-sdk is not working with aws..
+1
@devTalha
Can you share the code that's resulting in the error you're seeing?
Edit:
Oh I see, do you mean you're having an issue when trying to deploy a package with the aws-sdk included in a zip?
As an immediate workaround, adding 'ieee754': '1.1.8' to your dependencies will pull in a version that does not have files with a very old timestamp. It looks like the most recent version of this dependency still has very old timestamps for some of its files. We'll open an issue there to fix the timestamps, and can pin the dependency to 1.1.8 as well.
I have upgraded to v2.211.1 and done a clean install, but I still get this issue when running aws cloudformation deploy ....
Similar to @devTalha, the following command fixes things for me:
find ./node_modules -mtime +10950 -exec touch {} \;
Note, prior to running the above command, the following files appear to have very old modified dates:
$ find ./node_modules -mtime +10950
./node_modules/hosted-git-info/CHANGELOG.md
./node_modules/hosted-git-info/git-host-info.js
./node_modules/hosted-git-info/git-host.js
./node_modules/hosted-git-info/index.js
./node_modules/hosted-git-info/LICENSE
./node_modules/hosted-git-info/README.md
./node_modules/lru-cache/index.js
./node_modules/lru-cache/LICENSE
./node_modules/lru-cache/README.md
./node_modules/regexpp/index.d.ts
./node_modules/regexpp/index.js
./node_modules/regexpp/index.js.map
./node_modules/regexpp/LICENSE
./node_modules/regexpp/README.md
@chrisradek mentioned patch fixes the issue. But again i want aws to fix their issue as it spoiled my weekend roundly 48 hours. so anyone else doesn't have issue and aws-sdk works with aws pipeline. And yeah you got it right it happens when i add aws-sdk to my dependencies.
Thanks for concern.
@TonyFNZ and others
Zip files don't support files with timestamps prior to 1980. Some tools will get around this by actually changing dates to Jan 1 1980, but this is unexpected (and potentially dangerous) behavior.
The CodeBuild job that you're running is using the CLI (written in python) to generate a zip file. Python's zipfile module explicitly throws an error when it encounters files dated before 1980, rather than attempt to change the dates.
We patched the SDK so we could be sure none of our dependencies contained files dated prior to 1980. Any other library you're using that has the same problem would need to republish as well.
As an aside, it looks like there was an issue with NPM that was causing incorrect file timestamps, so it's likely this is what's leading to packages having incorrect dates:
https://github.com/npm/npm/issues/19968
wow, thanks @devTalha for starting this thread and everyone else for helping to solve it. I too just came in one morning to my projects that were using CodePipeline / CodeBuild and was in a panic because all of my projects were failing on the build stage with the exact same error (same one that op describes in his Logs but with my resource name), even ones whose source code I hadn't touched in months!
Anyway, after adding the command from @TonyFNZ after the npm install command my _buildspec.yml_ my build stages passed again, and it was smooth sailing.
version: 0.2
phases:
install:
commands:
# Install dependencies needed for running tests
- npm install
# Prevent files from having a timestamp before 1980
- find ./node_modules -mtime +10950 -exec touch {} \;
# Upgrade AWS CLI to the latest version
- pip install --upgrade awscli
pre_build:
commands:
# Discover and run unit tests in the 'tests' directory
- npm test
build:
commands:
# Use AWS SAM to package the application using AWS CloudFormation
- aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml
artifacts:
type: zip
files:
- template-export.yml
Case closed.
The problem is the version project and the version cloudformation nodejs.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
@zimny , @abajowski , @gbegher at the moment following patch fixed my issue:
I added following lines to buildspec.yml after 'npm install'
But i want aws to fix to this issue. I am really disappointed aws-sdk is not working with aws..