-
Notifications
You must be signed in to change notification settings - Fork 334
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
Implements a v2 Lambda Output with AssumeRole #1227
Conversation
@@ -2,6 +2,9 @@ | |||
"aws-lambda": { | |||
"sample-lambda": "function-name:qualifier" | |||
}, | |||
"aws-lambda-v2": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, this is not actually how this info will be written to the outputs.json
config file for AWSOutput
types .. see here:
streamalert/streamalert/alert_processor/outputs/aws.py
Lines 50 to 69 in 41da6b5
def format_output_config(cls, service_config, values): | |
"""Format the output configuration for this AWS service to be written to disk | |
AWS services are stored as a dictionary within the config instead of a list so | |
we have access to the AWS value (arn/bucket name/etc) for Terraform | |
Args: | |
service_config (dict): The actual outputs config that has been read in | |
values (OrderedDict): Contains all the OutputProperty items for this service | |
Returns: | |
dict{<string>: <string>}: Updated dictionary of descriptors and | |
values for this AWS service needed for the output configuration | |
NOTE: S3 requires the bucket name, not an arn, for this value. | |
Instead of implementing this differently in subclasses, all AWSOutput | |
subclasses should use a generic 'aws_value' to store the value for the | |
descriptor used in configuration | |
""" | |
return dict(service_config.get(cls.__service__, {}), | |
**{values['descriptor'].value: values['aws_value'].value}) |
did you confirm that this actually works as expected with the manage.py outputs new ...
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, no this is totally not gonna work. Good catch. No I didn't confirm it as I'm still testing it, but it's good to know that it's definitely wrong.
I think the easy fix is to just not inherit from this base class and just use the OutputDispatcher
base class like any other sane output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed - we can trend away from the AWSOutput class usage for future aws outputs now that ssm is a thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with one curiosity/question
I got this to work with Terraform configurations that look like:
|
* bumping version to 3.2.0 * migrating Athena function to use tf_lambda module (#1217) * rename of athena function * updating terraform generation code to use tf_lambda module * updating tf_athena module to remove lambda code * updates for packaging, rollback, and deploy * misc updates related to config path renaming, etc * removing no-longer-used method (athena is default) * addressing PR feedback * adding more granular time prefix to athena client * fixing duplicate resource issues (#1218) * fixing duplicate resource issues * fixing some other bugs in #1217 * fixing tf targets for athena deploy (#1220) * adding "--config-dir" flag to CLI to support specifying path for config files (#1224) * adding support for supplying path to config via CLI flag * misc touchups * updating publishers to accept configurable paths (#1223) * moving matchers outside of rules directory * updating rules for new matcher path * updating unit test for consistency * making publisher locations configurable * fixing typo * updating tf_lambda module to remove extra resources (#1225) * fixing rollback for all functions, removing 'all' flag for function deploys (#1222) * updating rollback functionality to include all funcs * updating tests to check for rollback of all funcs * updating docs * fixing tf cycle and index issue (#1226) * Add missing dependency (#1228) * Implements a v2 Lambda Output with AssumeRole (#1227) * First draft of aws-lambda-v2 * Tests * Fixup * Fixup * Fioxup * Fixup * fixup * adding terraform references for some buckets (#1229) * adding athena terraform references instead of literals * fixing tests * GitHub Actions (#1231) * port to github actions * remove travis * cover the 3.2 branch for now too * initial updates to simplify lambda packaging logic (#1232) * moving some precompiled files * initial revamp to packaging to remove multiple pacakges * taking out more trash * update scheduled queries module * updating deploy logic to suck garbage slightly less * updates to unit tests * addressing pr feedback * addressing PR feedback * small update to docs (#1233) Co-authored-by: Ryxias <[email protected]> Co-authored-by: Paul Kehrer <[email protected]>
to: @ryandeivert @blakemotl @chunyong-lin
cc: @airbnb/streamalert-maintainers
Background
We needed to be able to invoke Lambda across AWS accounts. The problem is the existing Lambda output seems to be.. wrong. It doesn't derive configs from the right place.
Instead of breaking reverse compatibility, I just added a v2 that is easier to set up and is more consistent with existing implementations. This v2 also has the ability to make
sts:AssumeRole
calls, in order to make Lambda invocations across accounts. However, it assumes that you already set up the IAM Policies correctly.Testing
Tested on stage; built a test lambda and was able to invoke it.