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

Added support of new features to the step_functions resource #365

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [1.12.0] - 2024-05-30
- Raised version of libraries `boto3` and `botocore`
- Added support of new features to the `step_functions` resource:
* update
* publish version
* state machine aliases

# [1.11.6] - 2024-05-24
- Added support of custom authorizer names in Open API specification security schemes
- Fixed quietness of errors while deploying/updating API Gateway via OpenAPI specification
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
click==7.1.2
botocore==1.29.80
boto3==1.26.80
botocore==1.34.113
boto3==1.34.113
tqdm==4.65.2
colorama==0.4.5
requests==2.31.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name='aws-syndicate',
version='1.11.6',
version='1.12.0',
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down
66 changes: 61 additions & 5 deletions syndicate/connection/step_functions_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,58 @@ def __init__(self, region=None, aws_access_key_id=None,
aws_session_token=aws_session_token)
_LOG.debug('Opened new Step Functions connection.')

def create_state_machine(self, machine_name, definition, role_arn):
def create_state_machine(self, machine_name, definition, role_arn,
publish_version=False, version_description=None):
params = {
'name': machine_name,
'roleArn': role_arn
}

if isinstance(definition, dict):
params['definition'] = dumps(definition)

if publish_version:
params['publish'] = True
if version_description:
params['versionDescription'] = str(version_description)
return self.client.create_state_machine(**params)

def update_state_machine(self, machine_arn, definition, role_arn,
publish_version=False, version_description=None):
params = {
'stateMachineArn': machine_arn,
'roleArn': role_arn
}

if isinstance(definition, dict):
definition = dumps(definition)
return self.client.create_state_machine(name=machine_name,
definition=definition,
roleArn=role_arn)
params['definition'] = dumps(definition)

if publish_version:
params['publish'] = True
if version_description:
params['versionDescription'] = str(version_description)
return self.client.update_state_machine(**params)

def create_state_machine_alias(self, name, routing_config,
description=None):
params = {
'name': name,
'routingConfiguration': routing_config
}
if description:
params['description'] = description
response = self.client.create_state_machine_alias(**params)
return response['stateMachineAliasArn']

def update_state_machine_alias(self, arn, routing_config,
description=None):
params = {
'stateMachineAliasArn': arn,
'routingConfiguration': routing_config
}
if description:
params['description'] = description
self.client.update_state_machine_alias(**params)

def describe_state_machine(self, arn):
try:
Expand All @@ -52,6 +98,16 @@ def describe_state_machine(self, arn):
else:
raise e

def describe_state_machine_alias(self, arn):
try:
return self.client.describe_state_machine_alias(
stateMachineAliasArn=arn)
except ClientError as e:
if 'ResourceNotFound' in str(e):
pass # valid exception
else:
raise e

def delete_state_machine(self, arn):
return self.client.delete_state_machine(stateMachineArn=arn)

Expand Down
3 changes: 2 additions & 1 deletion syndicate/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
EC2_LAUNCH_TEMPLATE_TYPE: 6,
BATCH_JOBDEF_TYPE: 7,
BATCH_COMPENV_TYPE: 8,
SWAGGER_UI_TYPE: 9
SWAGGER_UI_TYPE: 9,
STEP_FUNCTION_TYPE: 14
}

RESOURCE_LIST = list(DEPLOY_RESOURCE_TYPE_PRIORITY.keys())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ class StepFunctionGenerator(BaseDeploymentResourceGenerator):
"event_sources": list,
"dependencies": list,
"iam_role": None,
"publish_version": bool,
"alias": None
}
4 changes: 4 additions & 0 deletions syndicate/core/groups/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ def sns_topic(ctx, **kwargs):
help="Step function name")
@click.option('--iam_role', type=str, required=True,
help="IAM role to use for this state machine")
@click.option('--publish_version', type=bool, default=False,
help="Defines whether to publish the step function version")
@click.option('--alias', type=str,
help="Step function alias name")
@verbose_option
@click.pass_context
@timeit()
Expand Down
2 changes: 2 additions & 0 deletions syndicate/core/resources/processors_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ def update_handlers(self):
create_update_swagger_ui,
EC2_LAUNCH_TEMPLATE_TYPE:
self.resources_provider.ec2().update_launch_template,
STEP_FUNCTION_TYPE:
self.resources_provider.step_functions().update_state_machine
}

def resource_configuration_processor(self):
Expand Down
1 change: 1 addition & 0 deletions syndicate/core/resources/resources_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def step_functions(self):
iam_conn=self._conn_provider.iam(),
cw_events_conn=self._conn_provider.cw_events(),
lambda_conn=self._conn_provider.lambda_conn(),
lambda_res=self.lambda_resource(),
region=self.config.region,
account_id=self.config.account_id
)
Expand Down
Loading