-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix merge conflict in release 1.29.0 (#1771)
* Fix: Updated Slack Invite Link (#1712) * Updated Slack Invite Link * Restricted jsonschema to Python 2 * Forced pyrsistent to 0.16 in Python 2 * Reverted Changes to enum34 * Merge master back to develop (#1734) * Release v1.26.0 (#1680) * feat: add support for VPCEndpointIds in EndpointConfiguration * fix: update formatting with black * docs: update 2016-10-31.md * docs: added api endpointconfiguration example * docs: make example more generic * fix: remove nested EndpointConfiguration types from output * fix: only allow one EndpointConfiguration Type * doc: update example to reflect only allowing one EndpointConfiguration Type * fix : missing UserPool properties (#1506) (#1581) * fix: resource policy generation for {path+} (#1580) * refactor: Remove 2016-10-31 examples * update PR template * adjust pr template * Adding authorization scopes as list validation in ApiGatewayAuthorizer (v1 and v2). (#1670) * Adding authorization scopes as list validation in ApiGatewayAuthorizer and ApiGatewayV2Authorizer. * make black. * Adding functional test for invalid auth scope. * adding error condition for invalid test. * removing test template file. * feat: MSK event type support for AWS::Serverless::Function (#52) Co-authored-by: Steve Brown <[email protected]> Co-authored-by: jtaylor00 <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Tarun <[email protected]> * Update __init__.py (#1704) * Release/v1.27.0 resolveconflict (#1717) * Release v1.26.0 (#1680) * feat: add support for VPCEndpointIds in EndpointConfiguration * fix: update formatting with black * docs: update 2016-10-31.md * docs: added api endpointconfiguration example * docs: make example more generic * fix: remove nested EndpointConfiguration types from output * fix: only allow one EndpointConfiguration Type * doc: update example to reflect only allowing one EndpointConfiguration Type * fix : missing UserPool properties (#1506) (#1581) * fix: resource policy generation for {path+} (#1580) * refactor: Remove 2016-10-31 examples * update PR template * adjust pr template * Adding authorization scopes as list validation in ApiGatewayAuthorizer (v1 and v2). (#1670) * Adding authorization scopes as list validation in ApiGatewayAuthorizer and ApiGatewayV2Authorizer. * make black. * Adding functional test for invalid auth scope. * adding error condition for invalid test. * removing test template file. * feat: MSK event type support for AWS::Serverless::Function (#52) Co-authored-by: Steve Brown <[email protected]> Co-authored-by: jtaylor00 <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Tarun <[email protected]> * Fix: Updated Slack Invite Link (#1712) * Updated Slack Invite Link * Restricted jsonschema to Python 2 * Forced pyrsistent to 0.16 in Python 2 * Reverted Changes to enum34 Co-authored-by: Sriram Madapusi Vasudevan <[email protected]> Co-authored-by: Steve Brown <[email protected]> Co-authored-by: jtaylor00 <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Tarun <[email protected]> Co-authored-by: Cosh_ <[email protected]> Co-authored-by: Sriram Madapusi Vasudevan <[email protected]> Co-authored-by: Steve Brown <[email protected]> Co-authored-by: jtaylor00 <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Tarun <[email protected]> Co-authored-by: Mehmet Nuri Deveci <[email protected]> Co-authored-by: Cosh_ <[email protected]> * Lambdaauth (#1733) * Add support for Lambda Authorizers in HttpAPI * Address comments and fix formatting * fix version * Validate input parameters. Update tests * black reformat Co-authored-by: Raymond Wang <[email protected]> * Feature toggle (#1737) * Adding logic to pipe app config providers. Unit test pending * Adding some documentation to config providers. * Adding some unit tests and making black ignore json files. * minor cleanup. * Addressing PR comments. * feature: Support MTLS auth properties in REST and HTTP API domain names (#1725) * feature: Support MTLS auth properties in REST and HTTP API domain names * fix unicode != str issue in py2.7 * add SecurityPolicy because default RESTAPI is using TLS1.0 * Add new property DisableExecuteApiEndpoint * black reformat * Address comments * Add tests on invalid templates * address test failures in py2.7 * restart travis tests * fix: adding support for passing target id to EventBridgeRule (#1747) * Manage black version using requirement file (#1748) * chore: Manage black version in dev.txt - config pre-commit - config development guide - config travis Refer to the commit below in aws-sam-cli aws/aws-sam-cli@d725db5fbfc698a9f0c7582 * Format using black 20.8b1 * Opt-out black fron dev.txt for Python 2 * Release/v1.29.0 (#1769) * Mq event source (#60) * Support AmazonMQ as event source * Set black hook language version to python3 * chore: version bump (#64) * Black reformat Co-authored-by: Kaidi He <[email protected]> Co-authored-by: Cosh_ <[email protected]> Co-authored-by: Raymond Wang <[email protected]> Co-authored-by: Sriram Madapusi Vasudevan <[email protected]> Co-authored-by: Steve Brown <[email protected]> Co-authored-by: jtaylor00 <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Tarun <[email protected]> Co-authored-by: Mehmet Nuri Deveci <[email protected]> Co-authored-by: Tolledo <[email protected]> Co-authored-by: _sam <[email protected]> Co-authored-by: Kaidi He <[email protected]>
- Loading branch information
1 parent
df07ee4
commit 815b6aa
Showing
69 changed files
with
1,120 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# https://pre-commit.com/#repository-local-hooks | ||
repos: | ||
- repo: https://github.com/python/black | ||
rev: 19.3b0 | ||
hooks: | ||
- id: black | ||
language_version: python3.7 | ||
exclude_types: ['markdown', 'ini', 'toml', 'rst'] | ||
- repo: local | ||
hooks: | ||
- id: black | ||
name: black | ||
entry: black | ||
language: system | ||
types: [python] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ requests>=2.20.0 | |
|
||
# CLI requirements | ||
docopt>=0.6.2 | ||
|
||
# formatter | ||
black==20.8b1; python_version >= '3.6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.28.1" | ||
__version__ = "1.29.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import os | ||
import sys | ||
import json | ||
import boto3 | ||
import logging | ||
|
||
my_path = os.path.dirname(os.path.abspath(__file__)) | ||
sys.path.insert(0, my_path + "/..") | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class FeatureToggle: | ||
""" | ||
FeatureToggle is the class which will provide methods to query and decide if a feature is enabled based on where | ||
SAM is executing or not. | ||
""" | ||
|
||
def __init__(self, config_provider): | ||
self.feature_config = config_provider.config | ||
|
||
def is_enabled_for_stage_in_region(self, feature_name, stage, region="default"): | ||
""" | ||
To check if feature is available for a particular stage or not. | ||
:param feature_name: name of feature | ||
:param stage: stage where SAM is running | ||
:param region: region in which SAM is running | ||
:return: | ||
""" | ||
if feature_name not in self.feature_config: | ||
LOG.warning("Feature '{}' not available in Feature Toggle Config.".format(feature_name)) | ||
return False | ||
stage_config = self.feature_config.get(feature_name, {}).get(stage, {}) | ||
if not stage_config: | ||
LOG.info("Stage '{}' not enabled for Feature '{}'.".format(stage, feature_name)) | ||
return False | ||
region_config = stage_config.get(region, {}) if region in stage_config else stage_config.get("default", {}) | ||
is_enabled = region_config.get("enabled", False) | ||
LOG.info("Feature '{}' is enabled: '{}'".format(feature_name, is_enabled)) | ||
return is_enabled | ||
|
||
def is_enabled_for_account_in_region(self, feature_name, stage, account_id, region="default"): | ||
""" | ||
To check if feature is available for a particular account or not. | ||
:param feature_name: name of feature | ||
:param stage: stage where SAM is running | ||
:param account_id: account_id who is executing SAM template | ||
:param region: region in which SAM is running | ||
:return: | ||
""" | ||
if feature_name not in self.feature_config: | ||
LOG.warning("Feature '{}' not available in Feature Toggle Config.".format(feature_name)) | ||
return False | ||
stage_config = self.feature_config.get(feature_name, {}).get(stage, {}) | ||
if not stage_config: | ||
LOG.info("Stage '{}' not enabled for Feature '{}'.".format(stage, feature_name)) | ||
return False | ||
account_config = stage_config.get(account_id) if account_id in stage_config else stage_config.get("default", {}) | ||
region_config = ( | ||
account_config.get(region, {}) if region in account_config else account_config.get("default", {}) | ||
) | ||
is_enabled = region_config.get("enabled", False) | ||
LOG.info("Feature '{}' is enabled: '{}'".format(feature_name, is_enabled)) | ||
return is_enabled | ||
|
||
|
||
class FeatureToggleConfigProvider: | ||
"""Interface for all FeatureToggle config providers""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
@property | ||
def config(self): | ||
raise NotImplementedError | ||
|
||
|
||
class FeatureToggleDefaultConfigProvider(FeatureToggleConfigProvider): | ||
"""Default config provider, always return False for every query.""" | ||
|
||
def __init__(self): | ||
FeatureToggleConfigProvider.__init__(self) | ||
|
||
@property | ||
def config(self): | ||
return {} | ||
|
||
|
||
class FeatureToggleLocalConfigProvider(FeatureToggleConfigProvider): | ||
"""Feature toggle config provider which uses a local file. This is to facilitate local testing.""" | ||
|
||
def __init__(self, local_config_path): | ||
FeatureToggleConfigProvider.__init__(self) | ||
with open(local_config_path, "r") as f: | ||
config_json = f.read() | ||
self.feature_toggle_config = json.loads(config_json) | ||
|
||
@property | ||
def config(self): | ||
return self.feature_toggle_config | ||
|
||
|
||
class FeatureToggleAppConfigConfigProvider(FeatureToggleConfigProvider): | ||
"""Feature toggle config provider which loads config from AppConfig.""" | ||
|
||
def __init__(self, application_id, environment_id, configuration_profile_id): | ||
FeatureToggleConfigProvider.__init__(self) | ||
self.app_config_client = boto3.client("appconfig") | ||
try: | ||
response = self.app_config_client.get_configuration( | ||
Application=application_id, | ||
Environment=environment_id, | ||
Configuration=configuration_profile_id, | ||
ClientId="FeatureToggleAppConfigConfigProvider", | ||
) | ||
binary_config_string = response["Content"].read() | ||
self.feature_toggle_config = json.loads(binary_config_string.decode("utf-8")) | ||
except Exception as ex: | ||
LOG.error("Failed to load config from AppConfig: {}. Using empty config.".format(ex)) | ||
# There is chance that AppConfig is not available in a particular region. | ||
self.feature_toggle_config = json.loads("{}") | ||
|
||
@property | ||
def config(self): | ||
return self.feature_toggle_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.