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

SNS publishing can happen across region #3

Open
djhworld opened this issue Jul 19, 2015 · 0 comments
Open

SNS publishing can happen across region #3

djhworld opened this issue Jul 19, 2015 · 0 comments

Comments

@djhworld
Copy link

Hi @alestic

Sorry if this is the wrong place to post this.

In your blog post https://alestic.com/2015/05/aws-lambda-recurring-schedule/, it says the UTC is only available in us-east-1.

I've just been doing some reading of the AWS docs and it looks like this isn't a problem if your lambdas are in the supported regions

Q: What regions is AWS Lambda available in?
AWS Lambda is currently available in US East (N. Virginia), US West (Oregon) and EU (Ireland).
Q: Do my AWS Lambda functions need to be in the same region as my Amazon SNS usage?
You can subscribe your AWS Lambda functions to an Amazon SNS topic in any region.

I've tested this out on a lambda running in eu-west-1 and it works great.

To make this work with the script under the text "These commands subscribe an AWS Lambda function to the Unreliable Town Clock:" I've modified it slightly so anyone who's got lambdas in us-east-2 and eu-west-1 can subscribe to your topic

# AWS Lambda function
lambda_function_name=mylambda
lambda_function_region="eu-west-1"
account=000000000000
lambda_function_arn="arn:aws:lambda:$lambda_function_region:$account:function:$lambda_function_name"

# Unreliable Town Clock public SNS Topic
sns_topic_arn="arn:aws:sns:us-east-1:522480313337:unreliable-town-clock-topic-178F1OQACHTYF"

# Allow the SNS Topic to invoke the AWS Lambda function
aws lambda add-permission \
  --function-name "$lambda_function_name"  \
  --action lambda:InvokeFunction \
  --principal sns.amazonaws.com \
  --source-arn "$sns_topic_arn" \
  --statement-id $(uuidgen)

# Subscribe the AWS Lambda function to the SNS Topic in us-east-1
aws --region "us-east-1" sns subscribe \
  --topic-arn "$sns_topic_arn" \
  --protocol lambda \
  --notification-endpoint "$lambda_function_arn"
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

1 participant