Troposphere awslambda environment syntax

548 views
Skip to first unread message

Hamin

unread,
Jan 30, 2017, 8:28:46 AM1/30/17
to cloudtools-dev
I've been having trouble figuring out the syntax for awslambda environment variables

import troposphere.awslambda as awslambda
func = t.add_resource(awslambda.Function(
    "myFunction",
    Code=awslambda.Code(
        S3Bucket=Select(0,Ref(lambda_code_package)),
        S3Key=Select(1,Ref(lambda_code_package))
    ),
    FunctionName="myFunction",
    Handler="main.handler",
    Role=GetAtt(role,"Arn"),
    Runtime="python2.7",
    Timeout=300,
    Environment=awslambda.Environment(
        {
            "Variables": {"ENV_NAME": Ref(env_value}
        }
    )
))


Which gives me:
Traceback (most recent call last):
  File "function.py", line 112, in <module>
    "Variables": {"ENV_NAME": Ref(env_value)}
  File "/Library/Python/2.7/site-packages/troposphere/__init__.py", line 296, in __init__
    super(AWSProperty, self).__init__(title, **kwargs)
  File "/Library/Python/2.7/site-packages/troposphere/__init__.py", line 83, in __init__
    self.validate_title()
  File "/Library/Python/2.7/site-packages/troposphere/__init__.py", line 197, in validate_title
    if not valid_names.match(self.title):
TypeError: expected string or buffer

I'm guessing that I've missed something very simple but I cannot figure it out.  

Yvonne Beumer

unread,
Jan 30, 2017, 8:50:12 AM1/30/17
to Hamin, cloudtools-dev
Hello Hamin,

I think you're looking to use this:

    Environment=awslambda.Environment(
            Variables={"ENV_NAME": Ref(env_value)}
        )

Kind regards,
Yvonne

--
You received this message because you are subscribed to the Google Groups "cloudtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-dev+unsubscribe@googlegroups.com.
To post to this group, send email to cloudtools-dev@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/543c3115-6a68-4fdd-bdcf-d215128340dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Yvonne Beumer
Cloud Architect, Cloudreach Europe
[t] +31 202 610 424 (ext. 3003)
[m] +1 917 306 2496

Not if. When.

Check us out on Glassdoor!
@CloudreachKIC

The above terms reflect a potential business arrangement, are provided solely as a basis for further discussion, 
and are not intended to be and do not constitute a legally binding obligation. No legally binding obligations 
will be created, implied, or inferred until an agreement in final form is executed in writing by all parties involved.

This email may be confidential or privileged. If you received this communication by mistake, please don't forward 
it to anyone else, please erase all copies and attachments, and please let us know that it has gone to the wrong person.

Hamin

unread,
Jan 30, 2017, 9:01:54 AM1/30/17
to cloudtools-dev, ha...@hamin.se
Thank you, much appreciated!

-Hamin
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To post to this group, send email to cloudto...@googlegroups.com.



--
Yvonne Beumer
Cloud Architect, Cloudreach Europe
[t] +31 202 610 424 (ext. 3003)
[m] +1 917 306 2496

Not if. When.

Check us out on Glassdoor!
@CloudreachKIC
Reply all
Reply to author
Forward
0 new messages