Giter VIP home page Giter VIP logo

Comments (14)

mhart avatar mhart commented on September 26, 2024

Hey! Which Lambda runtime are you using?

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

NodeJs 10

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

Just re-read the readme. I misread it the first time apparently.

Switched the lambda to NodeJs 8.10 and get this:

START RequestId: d2270df8-6925-4922-b2ed-9857ca1d7237 Version: $LATEST
2019-10-02T12:27:23.873Z	d2270df8-6925-4922-b2ed-9857ca1d7237	{"errorMessage":"Command failed: git clone ssh://tfs.company.com:22/tfs/Production/_git/terraform-haproxy /tmp/terraform-haproxy","errorType":"Error","stackTrace":["checkExecSyncError (child_process.js:601:13)","execSync (child_process.js:641:13)","exports.handler (/var/task/index.js:43:3)"]}
END RequestId: d2270df8-6925-4922-b2ed-9857ca1d7237
REPORT RequestId: d2270df8-6925-4922-b2ed-9857ca1d7237	Duration: 243.34 ms	Billed Duration: 300 ms	Memory Size: 128 MB	Max Memory Used: 73 MB	

I'm either going blind or there's no useful error in there. :(

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

Well that's just the way you're invoking git with Node.js. I'm sure if you did something like:

execSync('git clone ...', { stdio: 'inherit' })

You'd be able to see the error (and I'm sure it's to do with SSH keys). See https://github.com/lambci/git-lambda-layer#complex-example-on-nodejs-w-ssh for how you might need to setup your SSH

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

ok, so this is what I'm using:

execSync('git clone ssh://tfs.company.com:22/tfs/Production/_git/terraform-haproxy /tmp/terraform-haproxy', { encoding: 'utf8', stdio: 'inherit' })
return execSync('ls /tmp/terraform-haproxy', { encoding: 'utf8' }).split('\n')

This returns null:
return execSync('git --version', { encoding: 'utf8', stdio: 'inherit' })

If I run the commands on my desktop then they work fine.

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

Yes, it will return null. That's how stdio: 'inherit' works – it outputs to stdout/stderr instead of returning. But then you can see the logs and so you'll be able to see where your problem is.

It doesn't look like you're specifying any ssh keys, so I'm pretty sure your ssh command won't work.

Unless there's an issue with this layer, then I'm going to close this issue

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

Yeah, didn't include the whole as it's just your sample code with the known_hosts, key and url changed.

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

Ok, well in that example I use stdio: 'inherit' for the git clone command, and that will output any errors to the logs, so you can see them in CloudWatch

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

ah ok, I see. I left the stdio: inherit part in but nothing is going to CloudWatch

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

So I just did a straight clone from a public repo to rule out ssh config issues.

execSync('git clone https://github.com/phpredis/phpredis.git /tmp/terraform-haproxy', { encoding: 'utf8', stdio: 'inherit' })

That times out after 3 seconds. I'm assuming that if no explicit VPC is set then the lambda has internet access. Is that correct?

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

I mean, it might be that the exception is killing the process before it has a chance to get the logs. You could try:

const { spawnSync } = require('child_process')
spawnSync('git', ['clone', 'ssh://tfs.company.com/tfs/Production/_git/terraform-haproxy', '/tmp/terraform-haproxy'], {stdio: 'inherit'})

instead (and then check the logs)

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

When you say it times out after 3 seconds – do you mean you've only got a 3 second timeout for your Lambda? (in which case, increase it) Or that the git process exits after 3 seconds?

from git-lambda-layer.

Richard-Payne avatar Richard-Payne commented on September 26, 2024

ok, I've worked out the CloudWatch issue. It was an IAM role issue.

The git problem is that it can't resolve the hostname, which is odd because it resolves fine from other hosts in the vpc.

Anyway, I think it's safe to say that this is no longer your issue. Thankyou for your help. Much appreciated.

from git-lambda-layer.

mhart avatar mhart commented on September 26, 2024

No probs, good luck!

from git-lambda-layer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.