Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Existing Lambdas #21

Open
hounded opened this issue Jan 10, 2019 · 3 comments
Open

Existing Lambdas #21

hounded opened this issue Jan 10, 2019 · 3 comments

Comments

@hounded
Copy link

hounded commented Jan 10, 2019

Hi Dmitri,
Loving you work and will be using greengo in our production devices.
What do you feel about using existing lambdas, as I deploy and manage all my lambdas with serverless, being able to use existing lambdas would be helpful something like;

ExistingLambdas:
  - name: d1Site
    aliasarn: arn:aws:lambda:<your lambda arn>
    greengrassConfig:
      MemorySize: 128000 # Kb, ask AWS why
      Timeout: 10 # Sec
      Pinned: True # Set True for long-lived functions
      Environment:
        AccessSysfs: False
        # ResourceAccessPolicies:
          # - ResourceId: 1_path_to_input
          #   Permission: 'rw'
        Variables:
           name: value
    def create_fn_defn(self):
        for l in self.group['ExistingLambdas']:
            functions = []
            functions.append({
                'Id': l['name'],
                'FunctionArn': l['aliasarn'],
                'FunctionConfiguration': l['greengrassConfig']
            })
            fd = self._gg.create_function_definition(
                Name=l['name'],
                InitialVersion={'Functions': functions}
            )
            self.state['FunctionDefinition'] = rinse(fd)
            _update_state(self.state)

            fd_ver = self._gg.get_function_definition_version(
                FunctionDefinitionId=self.state['FunctionDefinition']['Id'],
                FunctionDefinitionVersionId=self.state['FunctionDefinition']['LatestVersion'])

            self.state['FunctionDefinition']['LatestVersionDetails'] = rinse(fd_ver)
            _update_state(self.state)

This way I could run greengo create_fn_defn and I could deploy my existing lambda

@dzimine
Copy link
Owner

dzimine commented Jan 28, 2019

Thanks @hounded for the input: I have recently arrived to the same idea: we need support for Lambda that already exist. I'm split mind of how exactly:

Option 1: follow the AWS model and separate Lambdas from Lambda definitions. So that greengo.yaml will have two separate sections: Lambdas, where lambda functions defined in AWS Lambda, and LambdaDefinitions, which refer to both Lambdas defined inside greengo, and outside, by name. This is ideologically similar to your proposal just semantically different.

Option 2: keep Lambdas in one section for simplicity (don't expose AWS dirty underwear) but offer to refer existing Lambda by ARN... and may be by name? The absense of handler will indicate that the function is existing.

Lambdas:
  - name: NewLambda
    handler: function.handler
    package: lambdas/NewLambda
    alias: dev
    # role: 'arn:aws:iam::000000000000:role/base_lambda_role' # Use an existing role instead of auto-created one
    environment:
      foo: bar
    greengrassConfig:
      MemorySize: 128000 # Kb, ask AWS why
      Timeout: 10 # Sec
      Pinned: True # Set True for long-lived functions
      # the rest of AWS IoT function definition goes here

  -  name: my_existing_lambda  # refer already created Lambda by a name
    alias: dev
    environment:
      foo: bar
    greengrassConfig:
      MemorySize: 128000 # Kb, ask AWS why
      Timeout: 10 # Sec
      Pinned: True # Set True for long-lived functions
      # the rest of AWS IoT function definition goes here

I am leaning towards option 2. Appreciate your input.

PS. I am just back on refactoring greengo to v2 and want to incorporate ^ ^ into it.
PPS. Help appreciated :)

@dzimine dzimine mentioned this issue Jan 31, 2019
8 tasks
@hounded
Copy link
Author

hounded commented Feb 1, 2019

Hi Dimitri
right in the thick of it with deployment of hardware at the moment.
So are you going with option 2 ?
My coding level isn't probably on par with yours but am happy to make some pull requests.
Cheers

@dzimine
Copy link
Owner

dzimine commented Dec 10, 2019

Note that this is not added by @QuinnCiccoretti and available in v1; will also be available in v2 when eventually merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants