Skip to content

Instantly share code, notes, and snippets.

@beabetterdevv
Created January 24, 2023 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beabetterdevv/3437fe6e932b409d8b267a70f2905f6b to your computer and use it in GitHub Desktop.
Save beabetterdevv/3437fe6e932b409d8b267a70f2905f6b to your computer and use it in GitHub Desktop.
Config
---
{
"customerIds": ["1", "2", "3"]
}
Validator
---
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "My Config",
"type": "object",
"properties": {
"customerIds": {
"type": "array"
}
},
"minProperties": 1,
"required": [
"customerIds"
]
}
Policy
---
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudwatch:DescribeAlarms"
],
"Resource": "*"
}
]
}
Trust Relationship
---
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "appconfig.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Set Error State
---
aws cloudwatch set-alarm-state --alarm-name "LambdaErrorAlarm" --state-value ALARM --state-reason "testing purposes"
Lambda Code
---
import urllib.request
def lambda_handler(event, context):
url = f'http://localhost:2772/applications/application_name/environments/environment_name/configurations/configuration_name'
config = urllib.request.urlopen(url).read()
return config
Extensions / Layers Documentation
---
https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment