├── .cicd ├── __init__.py ├── blueprint.yaml └── test_manager.py ├── .circleci ├── config.yml ├── eks-inputs.yaml ├── hw.yaml ├── py3fixers └── test_cloudwatch.py ├── .drp └── trufflehog_config.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.txt ├── LICENSE ├── Makefile ├── README.md ├── cloudify_aws ├── __init__.py ├── __version__.py ├── autoscaling │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── autoscaling_group.py │ │ ├── launch_configuration.py │ │ ├── lifecycle_hook.py │ │ ├── notification_configuration.py │ │ └── policy.py │ └── tests │ │ ├── __init__.py │ │ ├── test_autoscaling_group.py │ │ ├── test_autoscalingbase.py │ │ ├── test_launch_configuration.py │ │ ├── test_lifecycle_hook.py │ │ └── test_policy.py ├── cloudformation │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ └── stack.py │ └── tests │ │ ├── __init__.py │ │ └── test_stack.py ├── cloudwatch │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── alarm.py │ │ ├── event.py │ │ ├── rule.py │ │ └── target.py │ └── tests │ │ ├── __init__.py │ │ ├── test_alarm.py │ │ ├── test_cloudwatchbase.py │ │ ├── test_event.py │ │ ├── test_rule.py │ │ └── test_target.py ├── codepipeline │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ └── pipeline.py │ └── tests │ │ ├── __init__.py │ │ └── test_pipeline.py ├── cognito │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── identity_pool.py │ │ ├── identity_provider.py │ │ ├── user_pool.py │ │ └── user_pool_client.py │ ├── scripts │ │ ├── params.py │ │ └── script.py │ └── tests │ │ ├── __init__.py │ │ ├── test_identity_pool.py │ │ ├── test_identity_provider.py │ │ ├── test_user_pool.py │ │ └── test_user_pool_client.py ├── common │ ├── __init__.py │ ├── _compat.py │ ├── connection.py │ ├── constants.py │ ├── decorators.py │ ├── tests │ │ ├── __init__.py │ │ ├── test_base.py │ │ ├── test_connection.py │ │ ├── test_constants.py │ │ ├── test_decorators.py │ │ ├── test_iface_requirement.py │ │ └── test_utils.py │ └── utils.py ├── dynamodb │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ └── table.py │ └── tests │ │ ├── __init__.py │ │ ├── test_dynamodbbase.py │ │ └── test_table.py ├── ec2 │ ├── __init__.py │ ├── decrypt.py │ ├── resources │ │ ├── __init__.py │ │ ├── customer_gateway.py │ │ ├── dhcp.py │ │ ├── ebs.py │ │ ├── elasticip.py │ │ ├── eni.py │ │ ├── image.py │ │ ├── instances.py │ │ ├── internet_gateway.py │ │ ├── keypair.py │ │ ├── nat_gateway.py │ │ ├── networkacl.py │ │ ├── networkaclentry.py │ │ ├── route.py │ │ ├── routetable.py │ │ ├── securitygroup.py │ │ ├── spot_fleet_request.py │ │ ├── spot_instances.py │ │ ├── subnet.py │ │ ├── tags.py │ │ ├── transit_gateway.py │ │ ├── transit_gateway_route.py │ │ ├── transit_gateway_routetable.py │ │ ├── vpc.py │ │ ├── vpc_peering.py │ │ ├── vpn_connection.py │ │ ├── vpn_connection_route.py │ │ └── vpn_gateway.py │ └── tests │ │ ├── __init__.py │ │ ├── test_customer_gateway.py │ │ ├── test_dhcp.py │ │ ├── test_ebs.py │ │ ├── test_ec2.py │ │ ├── test_ec2base.py │ │ ├── test_elasticip.py │ │ ├── test_eni.py │ │ ├── test_image.py │ │ ├── test_instances.py │ │ ├── test_internet_gateway.py │ │ ├── test_keypair.py │ │ ├── test_nat_gateway.py │ │ ├── test_networkacl.py │ │ ├── test_networkaclentry.py │ │ ├── test_route.py │ │ ├── test_routetable.py │ │ ├── test_spot_fleet_request.py │ │ ├── test_spot_instances.py │ │ ├── test_subnet.py │ │ ├── test_transit_gateway.py │ │ ├── test_transit_gateway_route.py │ │ ├── test_transit_gateway_routetable.py │ │ ├── test_vpc.py │ │ ├── test_vpc_peering.py │ │ ├── test_vpn_connection.py │ │ ├── test_vpn_connection_route.py │ │ └── test_vpn_gateway.py ├── ecr │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── authorization_token.py │ │ └── repository.py │ └── tests │ │ ├── __init__.py │ │ ├── test_auth_token.py │ │ └── test_repo.py ├── ecs │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── cluster.py │ │ ├── service.py │ │ └── task_definition.py │ └── tests │ │ ├── __init__.py │ │ ├── test_cluster.py │ │ ├── test_service.py │ │ └── test_task_definition.py ├── efs │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── file_system.py │ │ ├── mount_target.py │ │ └── tags.py │ └── tests │ │ ├── __init__.py │ │ ├── test_efs.py │ │ ├── test_file_system.py │ │ ├── test_mount_target.py │ │ └── test_tags.py ├── eks │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── cluster.py │ │ └── node_group.py │ └── tests │ │ ├── __init__.py │ │ ├── test_cluster.py │ │ └── test_nodegroup.py ├── elb │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── classic │ │ │ ├── __init__.py │ │ │ ├── health_check.py │ │ │ ├── listener.py │ │ │ ├── load_balancer.py │ │ │ └── policy.py │ │ ├── listener.py │ │ ├── load_balancer.py │ │ ├── rule.py │ │ └── target_group.py │ └── tests │ │ ├── __init__.py │ │ ├── test_classic_health_check.py │ │ ├── test_classic_listener.py │ │ ├── test_classic_load_balancer.py │ │ ├── test_classic_policy.py │ │ ├── test_elbbase.py │ │ ├── test_listener.py │ │ ├── test_load_balancer.py │ │ ├── test_rule.py │ │ └── test_target_group.py ├── iam │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── access_key.py │ │ ├── group.py │ │ ├── instance_profile.py │ │ ├── login_profile.py │ │ ├── policy.py │ │ ├── role.py │ │ ├── role_policy.py │ │ └── user.py │ └── tests │ │ ├── __init__.py │ │ ├── test_access_key.py │ │ ├── test_group.py │ │ ├── test_iambase.py │ │ ├── test_instance_profile.py │ │ ├── test_login_profile.py │ │ ├── test_policy.py │ │ ├── test_role.py │ │ ├── test_role_policy.py │ │ └── test_user.py ├── kms │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── alias.py │ │ ├── grant.py │ │ └── key.py │ └── tests │ │ ├── __init__.py │ │ ├── test_alias.py │ │ ├── test_grant.py │ │ ├── test_key.py │ │ └── test_kms.py ├── lambda_serverless │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── function.py │ │ ├── invoke.py │ │ └── permission.py │ └── tests │ │ ├── __init__.py │ │ ├── test_function.py │ │ ├── test_invoke.py │ │ ├── test_lambdabase.py │ │ └── test_permision.py ├── rds │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── instance.py │ │ ├── instance_read_replica.py │ │ ├── option.py │ │ ├── option_group.py │ │ ├── parameter.py │ │ ├── parameter_group.py │ │ └── subnet_group.py │ └── tests │ │ ├── __init__.py │ │ ├── test_base.py │ │ ├── test_instance.py │ │ ├── test_instance_read_replica.py │ │ ├── test_option.py │ │ ├── test_option_group.py │ │ ├── test_parameter.py │ │ ├── test_parameter_group.py │ │ ├── test_rds.py │ │ └── test_subnet_group.py ├── route53 │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── hosted_zone.py │ │ └── record_set.py │ └── tests │ │ ├── __init__.py │ │ ├── test_hosted_zone.py │ │ ├── test_record_set.py │ │ └── test_route53base.py ├── s3 │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── bucket.py │ │ ├── bucket_object.py │ │ ├── bucket_policy.py │ │ ├── lifecycle_configuration.py │ │ └── tagging.py │ └── tests │ │ ├── __init__.py │ │ ├── test_bucket.py │ │ ├── test_bucket_object.py │ │ ├── test_bucket_policy.py │ │ ├── test_lifecycle.py │ │ ├── test_s3base.py │ │ └── test_tagging.py ├── sns │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ ├── subscription.py │ │ └── topic.py │ └── tests │ │ ├── __init__.py │ │ ├── test_snsbase.py │ │ ├── test_subscription.py │ │ └── test_topic.py ├── sqs │ ├── __init__.py │ ├── resources │ │ ├── __init__.py │ │ └── queue.py │ └── tests │ │ ├── __init__.py │ │ ├── test_queue.py │ │ └── test_sqsbase.py └── workflows │ ├── __init__.py │ ├── check_status.py │ ├── discover.py │ ├── resources.py │ └── tests │ ├── __init__.py │ ├── test_check_status.py │ ├── test_discover.py │ └── test_utils.py ├── dev-requirements.txt ├── examples ├── autoscaling-feature-demo │ ├── blueprint.yaml │ ├── test.yaml │ └── variation.yaml ├── blueprint.yaml ├── cloudformation-feature-demo │ ├── blueprint.yaml │ ├── rds-stack-variation.yaml │ └── rds-stack.yaml ├── cloudwatch-feature-demo │ └── blueprint.yaml ├── codepipeline-feature-demo │ └── blueprint.yaml ├── cognito-feature-demo │ └── blueprint.yaml ├── dynamodb-feature-demo │ └── blueprint.yaml ├── ebs-feature-demo │ ├── blueprint.yaml │ └── ebs-to-ec2-instance.yaml ├── ec2-create-image-feature-demo │ └── blueprint.yaml ├── ec2-image-feature-demo │ └── blueprint.yaml ├── ec2-instance-feature-demo │ ├── eip-nic-blueprint.yaml │ └── elastic-ip.yaml ├── ec2-keys-feature-demo │ └── blueprint.yaml ├── ec2-spot-fleet-request │ ├── blueprint.yaml │ └── instance.yaml ├── ec2-spot-instances-feature-demo │ └── blueprint.yaml ├── ec2-transit-gateway-feature-demo │ └── blueprint.yaml ├── ec2-vpc-feature-demo │ ├── acl.yaml │ ├── blueprint.yaml │ ├── ipv6.yaml │ └── test.yaml ├── ecr-feature-demo │ └── blueprint.yaml ├── ecs-feature-demo │ └── blueprint.yaml ├── efs-feature-demo │ └── blueprint.yaml ├── eks-feature-demo │ ├── README.md │ ├── blueprint.yaml │ ├── resources │ │ └── template.yaml │ └── scripts │ │ └── store_kube_token_and_config.py ├── elb-feature-demo │ ├── application-elb-blueprint.yaml │ └── blueprint.yaml ├── iam-feature-demo │ └── blueprint.yaml ├── kms-feature-demo │ └── blueprint.yaml ├── lambda-feature-demo │ ├── blueprint.yaml │ └── function │ │ ├── main.py │ │ └── main.zip ├── natgateway-feature-demo │ └── blueprint.yaml ├── rds-feature-demo │ └── blueprint.yaml ├── route53-feature-demo │ └── blueprint.yaml ├── s3-feature-demo │ ├── blueprint.yaml │ ├── local-s3-object.txt │ └── swift-blueprint.yaml ├── security-group-feature-demo │ └── blueprint.yaml ├── sns-feature-demo │ └── blueprint.yaml ├── sqs-feature-demo │ └── blueprint.yaml └── virtual-machine │ └── aws-cloudformation.yaml ├── extra-packaging-instructions.sh ├── ignore_plugin_yaml_differences ├── plugin.yaml ├── plugin_1_4.yaml ├── plugin_1_5.yaml ├── pydoc └── __init__.py ├── requirements-3.6.in ├── requirements-3.6.txt ├── requirements.in ├── requirements.txt ├── setup.py ├── test-requirements.txt ├── tox.ini ├── v2_plugin.yaml └── webbrowser └── __init__.py /.cicd/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/.cicd/__init__.py -------------------------------------------------------------------------------- /.cicd/test_manager.py: -------------------------------------------------------------------------------- 1 | # ####### 2 | # Copyright (c) 2019 Cloudify Platform Ltd. All rights reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import os 17 | 18 | from integration_tests.tests.test_cases import PluginsTest 19 | 20 | DEVELOPMENT_ROOT = os.environ.get( 21 | 'REPO_BASE', 22 | os.path.join(os.path.expanduser('~'), 'dev/repos')) 23 | PLUGIN_NAME = 'cloudify-aws-plugin' 24 | TEST_KEY_PATH = '/tmp/foo.rsa' 25 | TEST_PUB_PATH = '/tmp/foo.rsa.pub' 26 | 27 | 28 | class AWSPluginTestCase(PluginsTest): 29 | 30 | base_path = os.path.dirname(os.path.realpath(__file__)) 31 | 32 | @property 33 | def plugin_root_directory(self): 34 | return os.path.abspath(os.path.join(self.base_path, '..')) 35 | 36 | @property 37 | def inputs(self): 38 | return { 39 | 'aws_region_name': os.getenv('aws_region_name', 40 | 'eu-central-1'), 41 | } 42 | 43 | def create_secrets(self): 44 | secrets = { 45 | 'agent_key_private': os.getenv('agent_key_private', 46 | open(TEST_KEY_PATH).read()), 47 | 'agent_key_public': os.getenv('agent_key_public', 48 | open(TEST_PUB_PATH).read()), 49 | 'aws_access_key_id': os.getenv('aws_access_key_id'), 50 | 'aws_secret_access_key': os.getenv( 51 | 'aws_secret_access_key'), 52 | 'aws_region_name': os.getenv('aws_region_name', 53 | 'eu-central-1'), 54 | 'aws_availability_zone': os.getenv('aws_availability_zone', 55 | 'eu-central-1b'), 56 | 'ec2_region_endpoint': os.getenv( 57 | 'ec2_region_endpoint', 58 | 'ec2.eu-central-1.amazonaws.com'), 59 | } 60 | self._create_secrets(secrets) 61 | 62 | def upload_plugins(self): 63 | self.upload_mock_plugin( 64 | PLUGIN_NAME, 65 | os.path.join(DEVELOPMENT_ROOT, PLUGIN_NAME)) 66 | self.upload_mock_plugin( 67 | 'cloudify-utilities-plugin', 68 | os.path.join(DEVELOPMENT_ROOT, 'cloudify-utilities-plugin')) 69 | self.upload_mock_plugin( 70 | 'cloudify-ansible-plugin', 71 | os.path.join(DEVELOPMENT_ROOT, 'cloudify-ansible-plugin')) 72 | 73 | def test_blueprints(self): 74 | self.upload_plugins() 75 | self.create_secrets() 76 | self.check_hello_world_blueprint('aws', self.inputs, 400) 77 | self.check_db_lb_app_blueprint('aws', 800) 78 | -------------------------------------------------------------------------------- /.circleci/eks-inputs.yaml: -------------------------------------------------------------------------------- 1 | aws_access_key_id: { get_secret: aws_access_key_id2 } 2 | aws_secret_access_key: { get_secret: aws_secret_access_key2} 3 | -------------------------------------------------------------------------------- /.circleci/hw.yaml: -------------------------------------------------------------------------------- 1 | ami_name_filter: 'ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*' 2 | aws_region_name: eu-west-3 3 | -------------------------------------------------------------------------------- /.circleci/py3fixers: -------------------------------------------------------------------------------- 1 | --stage1 2 | -f lib2to3.fixes.fix_getcwdu 3 | -f lib2to3.fixes.fix_long 4 | -f lib2to3.fixes.fix_nonzero 5 | -f lib2to3.fixes.fix_input 6 | -f lib2to3.fixes.fix_raw_input 7 | -f lib2to3.fixes.fix_itertools 8 | -f lib2to3.fixes.fix_itertools_imports 9 | -f lib2to3.fixes.fix_exec 10 | -f lib2to3.fixes.fix_operator 11 | -f libfuturize.fixes.fix_execfile 12 | -f libpasteurize.fixes.fix_newstyle 13 | -f lib2to3.fixes.fix_filter 14 | -f lib2to3.fixes.fix_map 15 | -f lib2to3.fixes.fix_zip 16 | -f lib2to3.fixes.fix_xrange 17 | -f lib2to3.fixes.fix_basestring 18 | -f libfuturize.fixes.fix_cmp 19 | -f libfuturize.fixes.fix_division_safe 20 | -f lib2to3.fixes.fix_metaclass 21 | -f libfuturize.fixes.fix_unicode_keep_u -------------------------------------------------------------------------------- /.circleci/test_cloudwatch.py: -------------------------------------------------------------------------------- 1 | ######## 2 | # Copyright (c) 2014-2019 Cloudify Platform Ltd. All rights reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | from os import environ 17 | from contextlib import contextmanager 18 | 19 | import pytest 20 | 21 | from ecosystem_tests.nerdl.api import ( 22 | upload_blueprint, 23 | delete_blueprint, 24 | delete_deployment, 25 | get_node_instance, 26 | create_deployment, 27 | wait_for_workflow, 28 | cleanup_on_failure, 29 | list_node_instances) 30 | 31 | TEST_ID = environ.get('__ECOSYSTEM_TEST_ID', 'hello-world-example') 32 | 33 | 34 | @contextmanager 35 | def test_cleaner_upper(): 36 | try: 37 | yield 38 | except Exception: 39 | cleanup_on_failure(TEST_ID) 40 | raise 41 | 42 | 43 | def test_cloudwatch(*_, **__): 44 | with test_cleaner_upper(): 45 | vm_props = cloud_resources_node_instance_runtime_properties() 46 | instance_id = vm_props.get('aws_resource_id') 47 | deployment_id = TEST_ID + 'cloudwatch' 48 | try: 49 | # Upload Cloud Watch Blueprint 50 | upload_blueprint( 51 | 'examples/cloudwatch-feature-demo/blueprint.yaml', 52 | deployment_id) 53 | # Create Cloud Watch Deployment with Instance ID input 54 | create_deployment( 55 | deployment_id, 56 | deployment_id, 57 | { 58 | "aws_instance_id": str(instance_id), 59 | "aws_region_name": "us-west-2" 60 | } 61 | ) 62 | # Install Cloud Watch Deployment 63 | wait_for_workflow(deployment_id, 'install', 1800) 64 | # Uninstall Cloud Watch Deployment 65 | wait_for_workflow(deployment_id, 'uninstall', 1800) 66 | delete_deployment(deployment_id) 67 | delete_blueprint(deployment_id) 68 | except: 69 | cleanup_on_failure(deployment_id) 70 | 71 | 72 | def cloud_resources_node_instance_runtime_properties(): 73 | node_instance = node_instance_by_name('vm') 74 | if not node_instance: 75 | raise RuntimeError('No cloud_resources node instances found.') 76 | runtime_properties = node_instance_runtime_properties( 77 | node_instance['id']) 78 | if not runtime_properties: 79 | raise RuntimeError( 80 | 'No cloud_resources runtime_properties found.') 81 | return runtime_properties 82 | 83 | 84 | def node_instance_by_name(name): 85 | for node_instance in list_node_instances(TEST_ID): 86 | if node_instance['node_id'] == name: 87 | return node_instance 88 | raise Exception('No node instances found.') 89 | 90 | 91 | def node_instance_runtime_properties(name): 92 | node_instance = get_node_instance(name) 93 | return node_instance['runtime_properties'] 94 | -------------------------------------------------------------------------------- /.drp/trufflehog_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | project_exclusion_list: 3 | exclusion_folders: 4 | - .drp 5 | - .github 6 | - examples 7 | - cloudify_aws/s3/tests 8 | # - test 9 | # - jenkins 10 | # - buildroot 11 | # - buildroot 12 | exclusion_file_paths: 13 | - Makefile 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | 91 | # Cloudify 92 | inputs.yaml 93 | local-storage/ 94 | .cloudify/ 95 | 96 | # IDE settings 97 | .idea 98 | .DS_Store 99 | 100 | plugin_docs 101 | workspace 102 | *.wgn 103 | cloudify-utilities-plugins-sdk 104 | fusion-agent 105 | fusion-common 106 | fusion-manager 107 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "examples/blueprint-examples"] 2 | path = examples/blueprint-examples 3 | url = https://github.com/cloudify-community/blueprint-examples.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | download: 2 | ifeq (,$(wildcard ./fusion-agent)) 3 | git clone https://${GH_USER}:${GITHUB_PASSWORD}@eos2git.cec.lab.emc.com/ISG-Edge/fusion-agent.git && cd './fusion-agent' && git checkout master && cd .. 4 | endif 5 | ifeq (,$(wildcard ./fusion-common)) 6 | git clone https://${GH_USER}:${GITHUB_PASSWORD}@eos2git.cec.lab.emc.com/ISG-Edge/fusion-common.git && cd './fusion-common' && git checkout master && cd .. 7 | endif 8 | ifeq (,$(wildcard ./fusion-manager)) 9 | git clone https://${GH_USER}:${GITHUB_PASSWORD}@eos2git.cec.lab.emc.com/ISG-Edge/fusion-manager.git && cd './fusion-manager' && git checkout master && cd .. 10 | endif 11 | ifeq (,$(wildcard ./cloudify-utilities-plugins-sdk)) 12 | git clone https://github.com/cloudify-incubator/cloudify-utilities-plugins-sdk.git && cd './cloudify-utilities-plugins-sdk' && git checkout fusion && cd .. 13 | endif 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cloudify-aws-plugin 2 | =================== 3 | 4 | A Cloudify Plugin that provisions resources in Amazon Web Services 5 | 6 | ## Usage 7 | See [AWS Plugin](http://docs.getcloudify.org/latest/plugins/aws/) 8 | 9 | 10 | # Requirements 11 | boto3 AWS Python Library version 1.9.57 12 | 13 | # Examples 14 | For official blueprint examples using this Cloudify plugin, please see [Cloudify Community Blueprints Examples](https://github.com/cloudify-community/blueprint-examples/). 15 | -------------------------------------------------------------------------------- /cloudify_aws/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/__version__.py: -------------------------------------------------------------------------------- 1 | version = '3.2.4' 2 | -------------------------------------------------------------------------------- /cloudify_aws/autoscaling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | Autoscaling 16 | ~~~ 17 | AWS Autoscaling base interface 18 | ''' 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class AutoscalingBase(AWSResourceBase): 27 | ''' 28 | AWS ELB base interface 29 | ''' 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('autoscaling'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | '''Gets the properties of an external resource''' 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | '''Gets the status of an external resource''' 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | '''Creates a resource''' 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | '''Deletes a resource''' 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/autoscaling/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/autoscaling/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/autoscaling/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/autoscaling/tests/test_autoscalingbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.autoscaling import AutoscalingBase 21 | 22 | 23 | class TestAutoscalingBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestAutoscalingBase, self).setUp() 27 | self.base = AutoscalingBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/cloudformation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | CloudFormation 16 | ~~~ 17 | AWS CloudFormation base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class AWSCloudFormationBase(AWSResourceBase): 27 | """ 28 | AWS CloudFormation interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, 33 | client or Boto3Connection(ctx_node).client('cloudformation'), 34 | resource_id=resource_id, 35 | logger=logger) 36 | 37 | @property 38 | def properties(self): 39 | """Gets the properties of an external resource""" 40 | raise NotImplementedError() 41 | 42 | @property 43 | def status(self): 44 | """Gets the status of an external resource""" 45 | raise NotImplementedError() 46 | 47 | def create(self, params): 48 | """Creates a resource""" 49 | raise NotImplementedError() 50 | 51 | def delete(self, params=None): 52 | """Deletes a resource""" 53 | raise NotImplementedError() 54 | -------------------------------------------------------------------------------- /cloudify_aws/cloudformation/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/cloudformation/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/cloudformation/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/cloudformation/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | Cloudwatch 16 | ~~~ 17 | AWS Cloudwatch base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class AWSCloudwatchBase(AWSResourceBase): 27 | """ 28 | AWS Cloudwatch interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, 33 | client or Boto3Connection(ctx_node).client('cloudwatch'), 34 | resource_id=resource_id, 35 | logger=logger) 36 | 37 | @property 38 | def properties(self): 39 | """Gets the properties of an external resource""" 40 | raise NotImplementedError() 41 | 42 | @property 43 | def status(self): 44 | """Gets the status of an external resource""" 45 | raise NotImplementedError() 46 | 47 | def create(self, params): 48 | """Creates a resource""" 49 | raise NotImplementedError() 50 | 51 | def delete(self, params=None): 52 | """Deletes a resource""" 53 | raise NotImplementedError() 54 | -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/resources/alarm.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | Cloudwatch.alarm 16 | ~~~~~~~~~~~~~~ 17 | AWS Cloudwatch Alarm interface 18 | """ 19 | # Third party imports 20 | from botocore.exceptions import ClientError, ParamValidationError 21 | 22 | # Local imports 23 | from cloudify_aws.common import decorators, utils 24 | from cloudify_aws.cloudwatch import AWSCloudwatchBase 25 | 26 | RESOURCE_TYPE = 'Cloudwatch Alarm' 27 | RESOURCE_NAME = 'AlarmName' 28 | RESOURCE_NAMES = 'AlarmNames' 29 | METRIC_ALARMS = 'MetricAlarms' 30 | 31 | 32 | class CloudwatchAlarm(AWSCloudwatchBase): 33 | """ 34 | AWS Cloudwatch Alarm interface 35 | """ 36 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 37 | AWSCloudwatchBase.__init__(self, ctx_node, resource_id, client, logger) 38 | self.type_name = RESOURCE_TYPE 39 | 40 | @property 41 | def properties(self): 42 | """Gets the properties of an external resource""" 43 | if not self.resource_id: 44 | return 45 | params = {RESOURCE_NAMES: [self.resource_id]} 46 | try: 47 | resources = \ 48 | self.client.describe_alarms(**params) 49 | except (ParamValidationError, ClientError): 50 | pass 51 | else: 52 | return resources.get(METRIC_ALARMS, [None])[0] 53 | 54 | @property 55 | def status(self): 56 | """Gets the status of an external resource""" 57 | return None 58 | 59 | def create(self, params): 60 | """ 61 | Create a new AWS Cloudwatch Alarm. 62 | """ 63 | return self.make_client_call('put_metric_alarm', params) 64 | 65 | def delete(self, params=None): 66 | """ 67 | Deletes an existing AWS Cloudwatch Alarm. 68 | """ 69 | self.logger.debug('Deleting %s with parameters: %s' 70 | % (self.type_name, params)) 71 | res = self.client.delete_alarms(**params) 72 | self.logger.debug('Response: %s' % res) 73 | return res 74 | 75 | 76 | @decorators.aws_resource(CloudwatchAlarm, RESOURCE_TYPE) 77 | def prepare(ctx, resource_config, **_): 78 | """Prepares an AWS Cloudwatch Alarm""" 79 | # Save the parameters 80 | ctx.instance.runtime_properties['resource_config'] = resource_config 81 | 82 | 83 | @decorators.aws_resource(CloudwatchAlarm, RESOURCE_TYPE) 84 | def create(ctx, iface, resource_config, **_): 85 | """Creates an AWS Cloudwatch Alarm""" 86 | resource_id = \ 87 | iface.resource_id or \ 88 | utils.get_resource_id( 89 | ctx.node, 90 | ctx.instance, 91 | resource_config.get(RESOURCE_NAME), 92 | use_instance_id=True) 93 | resource_config[RESOURCE_NAME] = resource_id 94 | utils.update_resource_id(ctx.instance, resource_id) 95 | if not iface.resource_id: 96 | setattr(iface, 'resource_id', resource_config.get(RESOURCE_NAME)) 97 | 98 | # Actually create the resource 99 | iface.create(resource_config) 100 | 101 | 102 | @decorators.aws_resource(CloudwatchAlarm, RESOURCE_TYPE, 103 | ignore_properties=True) 104 | def delete(iface, resource_config, **_): 105 | """Deletes an AWS Cloudwatch Alarm""" 106 | if RESOURCE_NAMES not in resource_config: 107 | resource_config.update({RESOURCE_NAMES: [iface.resource_id]}) 108 | iface.delete(resource_config) 109 | -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/resources/event.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | Cloudwatch.Events.Event 16 | ~~~~~~~~~~~~~~ 17 | AWS Cloudwatch Events Event interface 18 | """ 19 | # Cloudify 20 | from cloudify_aws.common import decorators 21 | from cloudify_aws.cloudwatch import AWSCloudwatchBase 22 | from cloudify_aws.common.connection import Boto3Connection 23 | 24 | RESOURCE_TYPE = 'Cloudwatch Event' 25 | 26 | 27 | class CloudwatchEvent(AWSCloudwatchBase): 28 | """ 29 | AWS Cloudwatch Events Event interface 30 | """ 31 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 32 | AWSCloudwatchBase.__init__( 33 | self, 34 | ctx_node, 35 | resource_id, 36 | client or Boto3Connection(ctx_node).client('events'), 37 | logger) 38 | self.type_name = RESOURCE_TYPE 39 | 40 | @property 41 | def properties(self): 42 | """Gets the properties of an external resource""" 43 | return None 44 | 45 | @property 46 | def status(self): 47 | """Gets the status of an external resource""" 48 | return None 49 | 50 | def create(self, params): 51 | """ 52 | Create a new AWS Cloudwatch Events Event. 53 | """ 54 | return self.make_client_call('put_events', params) 55 | 56 | def delete(self, params=None): 57 | return None 58 | 59 | 60 | @decorators.aws_resource(CloudwatchEvent, RESOURCE_TYPE) 61 | def prepare(ctx, resource_config, **_): 62 | """Prepares an AWS Cloudwatch Events Event""" 63 | # Save the parameters 64 | ctx.instance.runtime_properties['resource_config'] = resource_config 65 | 66 | 67 | @decorators.aws_resource(CloudwatchEvent, RESOURCE_TYPE) 68 | def create(iface, resource_config, **_): 69 | """Creates an AWS Cloudwatch Events Event""" 70 | iface.create(resource_config) 71 | -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/cloudwatch/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/cloudwatch/tests/test_cloudwatchbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.cloudwatch import AWSCloudwatchBase 21 | 22 | 23 | class TestAWSCloudwatchBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestAWSCloudwatchBase, self).setUp() 27 | self.base = AWSCloudwatchBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/codepipeline/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | CodePipeline 16 | ~~~ 17 | AWS CodePipline base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | 24 | class CodePipelineBase(AWSResourceBase): 25 | """ 26 | AWS CodePipline base interface 27 | """ 28 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 29 | AWSResourceBase.__init__( 30 | self, client or Boto3Connection(ctx_node).client('codepipeline'), 31 | resource_id=resource_id, logger=logger) 32 | 33 | @property 34 | def properties(self): 35 | """Gets the properties of an external resource""" 36 | raise NotImplementedError() 37 | 38 | @property 39 | def status(self): 40 | """Gets the status of an external resource""" 41 | raise NotImplementedError() 42 | 43 | def create(self, params): 44 | """Creates a resource""" 45 | raise NotImplementedError() 46 | 47 | def delete(self, params=None): 48 | """Deletes a resource""" 49 | raise NotImplementedError() 50 | -------------------------------------------------------------------------------- /cloudify_aws/codepipeline/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /cloudify_aws/codepipeline/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/codepipeline/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/cognito/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | Cognito 16 | ~~~~~~~ 17 | AWS Cognito base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class CognitoBase(AWSResourceBase): 27 | """ 28 | AWS Cognito base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('cognito-idp'), 33 | resource_id=resource_id, logger=logger) 34 | self.ctx_node = ctx_node 35 | 36 | @property 37 | def properties(self): 38 | """Gets the properties of an external resource""" 39 | raise NotImplementedError() 40 | 41 | @property 42 | def status(self): 43 | """Gets the status of an external resource""" 44 | raise NotImplementedError() 45 | 46 | def create(self, params): 47 | """Creates a resource""" 48 | raise NotImplementedError() 49 | 50 | def delete(self, params=None): 51 | """Deletes a resource""" 52 | raise NotImplementedError() 53 | 54 | 55 | class CognitoIdentityBase(AWSResourceBase): 56 | """ 57 | AWS Cognito base interface 58 | """ 59 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 60 | AWSResourceBase.__init__( 61 | self, 62 | client or Boto3Connection(ctx_node).client('cognito-identity'), 63 | resource_id=resource_id, logger=logger) 64 | self.ctx_node = ctx_node 65 | -------------------------------------------------------------------------------- /cloudify_aws/cognito/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/cognito/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/cognito/resources/user_pool.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | Cognito.user_pool 17 | ~~~~~~~~ 18 | AWS Cognito User Pool interface 19 | """ 20 | 21 | # Third party imports 22 | from botocore.exceptions import ( 23 | ClientError, 24 | ParamValidationError) 25 | 26 | # Local imports 27 | from cloudify_aws.cognito import CognitoBase 28 | from cloudify_aws.common import decorators, utils 29 | 30 | RESOURCE_NAME = 'PoolName' 31 | DESCRIBE_INDEX = 'UserPool' 32 | RESOURCE_TYPE = 'Cognito User Pool' 33 | 34 | 35 | class CognitoUserPool(CognitoBase): 36 | """ 37 | AWS Cognito User Pool interface 38 | """ 39 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 40 | CognitoBase.__init__(self, ctx_node, resource_id, client, logger) 41 | self.type_name = RESOURCE_TYPE 42 | 43 | @property 44 | def properties(self): 45 | """Gets the properties of an external resource""" 46 | if self.resource_id: 47 | try: 48 | resource = self.client.describe_user_pools( 49 | UserPoolId=self.resource_id) 50 | except (ParamValidationError, ClientError): 51 | pass 52 | else: 53 | return resource.get(DESCRIBE_INDEX, {}) 54 | return {} 55 | 56 | @property 57 | def status(self): 58 | """Gets the status of an external resource""" 59 | return self.properties.get('Status') 60 | 61 | def create(self, params): 62 | """Create a new AWS Cognito User Pool.""" 63 | return self.make_client_call('create_user_pool', params) 64 | 65 | def delete(self, params=None): 66 | """Delete a new AWS Cognito User Pool.""" 67 | return self.make_client_call('delete_user_pool', params) 68 | 69 | 70 | @decorators.aws_resource(CognitoUserPool, RESOURCE_TYPE) 71 | def prepare(ctx, resource_config, **_): 72 | """Prepares an AWS Cognito User Pool""" 73 | # Save the parameters 74 | ctx.instance.runtime_properties['resource_config'] = resource_config 75 | 76 | 77 | @decorators.aws_resource(CognitoUserPool, RESOURCE_TYPE) 78 | def create(ctx, iface, resource_config, **_): 79 | """Creates an AWS Cognito User Pool""" 80 | create_response = utils.raise_on_substring( 81 | iface, 82 | 'create', 83 | resource_config, 84 | 'Role does not have a trust relationship') 85 | utils.update_resource_id( 86 | ctx.instance, 87 | create_response['UserPool']['Id']) 88 | utils.update_resource_arn( 89 | ctx.instance, 90 | create_response['UserPool']['Arn']) 91 | ctx.instance.runtime_properties['create_response'] = \ 92 | utils.JsonCleanuper(create_response).to_dict() 93 | 94 | 95 | @decorators.aws_resource(CognitoUserPool, 96 | RESOURCE_TYPE, 97 | ignore_properties=True) 98 | def delete(iface, resource_config, **_): 99 | """Deletes an AWS Cognito User Pool""" 100 | iface.delete( 101 | { 102 | 'UserPoolId': utils.get_resource_id() 103 | } 104 | ) 105 | -------------------------------------------------------------------------------- /cloudify_aws/cognito/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/cognito/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/common/_compat.py: -------------------------------------------------------------------------------- 1 | ######## 2 | # Copyright (c) 2020 Cloudify Platform Ltd. All rights reserved 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # * See the License for the specific language governing permissions and 14 | # * limitations under the License. 15 | 16 | # flake8: noqa 17 | # pylint: skip-file 18 | 19 | import sys 20 | PY2 = sys.version_info[0] == 2 21 | 22 | if PY2: 23 | from urllib2 import urlopen 24 | from urlparse import urljoin 25 | try: 26 | from cStringIO import StringIO 27 | except ImportError: 28 | from StringIO import StringIO 29 | reload_module = reload 30 | text_type = unicode 31 | else: 32 | from io import StringIO 33 | from imp import reload as reload_module 34 | from urllib.parse import urljoin 35 | from urllib.request import urlopen 36 | text_type = str 37 | 38 | __all__ = [ 39 | 'PY2', 'text_type', 'urljoin', 40 | 'urlopen', 'StringIO', 'reload_module' 41 | ] -------------------------------------------------------------------------------- /cloudify_aws/common/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | Common.Constants 16 | ~~~~~~~~~~~~~~~~ 17 | AWS constants 18 | ''' 19 | 20 | AWS_CONFIG_PROPERTY = 'client_config' 21 | EXTERNAL_RESOURCE_ID = 'aws_resource_id' 22 | EXTERNAL_RESOURCE_ID_MULTIPLE = 'aws_resource_ids' 23 | EXTERNAL_RESOURCE_ARN = 'aws_resource_arn' 24 | TAG_SPECIFICATIONS_KWARG = 'TagSpecifications' 25 | 26 | REL_CONTAINED_IN = 'cloudify.relationships.contained_in' 27 | ARN_REGEX = '^arn\:aws\:' 28 | REGION_REGEX = ( 29 | '^[a-z]{2}\-([a-z]{4,10}|[a-z]{3}\-[a-z]{4,10})\-[1-3]{1}$' 30 | ) 31 | AVAILABILITY_ZONE_REGEX = ( 32 | '^[a-z]{2}\-([a-z]{4,10}|[a-z]{3}\-[a-z]{4,10})\-[1-3]{1}[a-z]{1}$' 33 | ) 34 | 35 | SWIFT_NODE_PREFIX = 'cloudify.nodes.swift' 36 | SWIFT_ERROR_TOKEN_CODE = 'SignatureDoesNotMatch' 37 | 38 | 39 | MAX_AWS_NAME = 255 40 | 41 | LOCATIONS = { 42 | 'ap-northeast-1': { 43 | 'coordinates': '35.6828387, 139.7594549', 44 | 'town': 'Tokyo' 45 | }, 46 | 'ap-northeast-2': { 47 | 'coordinates': '37.5666791, 126.9782914', 48 | 'town': 'Seoul' 49 | }, 50 | 'ap-northeast-3': { 51 | 'coordinates': '34.6198813, 135.490357', 52 | 'town': 'Osaka' 53 | }, 54 | 'ap-south-1': { 55 | 'coordinates': '19.0759899, 72.8773928', 56 | 'town': 'Mumbai' 57 | }, 58 | 'ap-southeast-1': { 59 | 'coordinates': '1.357107, 103.8194992', 60 | 'town': 'Singapore' 61 | }, 62 | 'ap-southeast-2': { 63 | 'coordinates': '-33.8548157, 151.2164539', 64 | 'town': 'Sydney' 65 | }, 66 | 'ca-central-1': { 67 | 'coordinates': '45.4972159, -73.6103642', 68 | 'town': 'Montreal' 69 | }, 70 | 'eu-central-1': { 71 | 'coordinates': '50.1106444, 8.6820917', 72 | 'town': 'Frankfurt' 73 | }, 74 | 'eu-north-1': { 75 | 'coordinates': '59.3251172, 18.0710935', 76 | 'town': 'Stockholm' 77 | }, 78 | 'eu-west-1': { 79 | 'coordinates': '52.865196, -7.9794599', 80 | 'town': 'Ireland' 81 | }, 82 | 'eu-west-2': { 83 | 'coordinates': '51.5073219, -0.1276474', 84 | 'town': 'London' 85 | }, 86 | 'eu-west-3': { 87 | 'coordinates': '48.8566969, 2.3514616', 88 | 'town': 'Paris' 89 | }, 90 | 'sa-east-1': { 91 | 'coordinates': '-23.5506507, -46.6333824', 92 | 'town': 'Sao Paulo' 93 | }, 94 | 'us-east-1': { 95 | 'coordinates': '39.0438, -77.4874', 96 | 'town': 'Ashburn, VA' 97 | }, 98 | 'us-east-2': { 99 | 'coordinates': '40.1536742, -82.6851699', 100 | 'town': 'Johnstown, OH' 101 | }, 102 | 'us-west-1': { 103 | 'coordinates': '37.0065078, -121.5631723', 104 | 'town': 'Gilroy, CA' 105 | }, 106 | 'us-west-2': { 107 | 'coordinates': '45.839855, -119.7005834', 108 | 'town': 'Boardman, OR' 109 | } 110 | } 111 | 112 | SUPPORT_DRIFT = [ 113 | 'cloudify.nodes.aws.ec2.Vpc', 114 | 'cloudify.nodes.aws.ec2.Subnet', 115 | 'cloudify.nodes.aws.ec2.Interface', 116 | 'cloudify.nodes.aws.ec2.SecurityGroup', 117 | 'cloudify.nodes.aws.ec2.Instances', 118 | 'cloudify.nodes.aws.eks.Cluster', 119 | 'cloudify.nodes.aws.eks.NodeGroup', 120 | ] 121 | -------------------------------------------------------------------------------- /cloudify_aws/common/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/common/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/common/tests/test_connection.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import copy 16 | import unittest 17 | from mock import patch, MagicMock 18 | from cloudify.state import current_ctx 19 | 20 | 21 | from cloudify_aws.common.connection import Boto3Connection 22 | from cloudify_aws.common.tests.test_base import TestBase, CLIENT_CONFIG 23 | 24 | 25 | class TestConnection(TestBase): 26 | 27 | def setUp(self): 28 | super(TestConnection, self).setUp() 29 | 30 | self.fake_boto, self.fake_client = self.fake_boto_client('other') 31 | 32 | self.mock_patch = patch('boto3.client', self.fake_boto) 33 | self.mock_patch.start() 34 | 35 | def tearDown(self): 36 | self.mock_patch.stop() 37 | self.fake_boto = None 38 | self.fake_client = None 39 | 40 | super(TestConnection, self).tearDown() 41 | 42 | def test_client_direct_params(self): 43 | 44 | node = MagicMock() 45 | node.properties = {} 46 | _ctx = self.get_mock_ctx('test') 47 | current_ctx.set(_ctx) 48 | 49 | connection = Boto3Connection(node, copy.deepcopy(CLIENT_CONFIG)) 50 | connection.client('abc') 51 | 52 | self.fake_boto.assert_called_with( 53 | 'abc', **CLIENT_CONFIG 54 | ) 55 | 56 | def test_client_node_params(self): 57 | 58 | node = MagicMock() 59 | node.properties = { 60 | 'client_config': copy.deepcopy(CLIENT_CONFIG) 61 | } 62 | _ctx = self.get_mock_ctx('test') 63 | current_ctx.set(_ctx) 64 | 65 | connection = Boto3Connection(node, {'a': 'b'}) 66 | connection.client('abc') 67 | 68 | self.fake_boto.assert_called_with( 69 | 'abc', **CLIENT_CONFIG 70 | ) 71 | 72 | self.assertEqual(connection.aws_config, CLIENT_CONFIG) 73 | 74 | def test_client_session_token(self): 75 | 76 | node = MagicMock() 77 | node.properties = { 78 | 'client_config': { 79 | 'aws_session_token': 'foo', 80 | 'region_name': 'bar' 81 | } 82 | } 83 | _ctx = self.get_mock_ctx('test') 84 | current_ctx.set(_ctx) 85 | 86 | connection = Boto3Connection(node, {'a': 'b'}) 87 | connection.client('abc') 88 | 89 | self.fake_boto.assert_called_with( 90 | 'abc', **{ 91 | 'aws_session_token': 'foo', 92 | 'region_name': 'bar' 93 | } 94 | ) 95 | 96 | self.assertEqual( 97 | connection.aws_config, { 98 | 'aws_session_token': 'foo', 99 | 'region_name': 'bar' 100 | } 101 | ) 102 | 103 | 104 | if __name__ == '__main__': 105 | unittest.main() 106 | -------------------------------------------------------------------------------- /cloudify_aws/common/tests/test_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import unittest 16 | 17 | from cloudify_aws.common import constants 18 | 19 | 20 | class TestConstants(unittest.TestCase): 21 | 22 | def test_default_constants(self): 23 | self.assertEqual(constants.AWS_CONFIG_PROPERTY, 'client_config') 24 | self.assertEqual(constants.EXTERNAL_RESOURCE_ID, 'aws_resource_id') 25 | self.assertEqual(constants.EXTERNAL_RESOURCE_ARN, 'aws_resource_arn') 26 | self.assertEqual(constants.REL_CONTAINED_IN, 27 | 'cloudify.relationships.contained_in') 28 | 29 | 30 | if __name__ == '__main__': 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /cloudify_aws/dynamodb/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | DynamoDB 16 | ~~~~~~~~ 17 | AWS DynamoDB base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class DynamoDBBase(AWSResourceBase): 27 | """ 28 | AWS DynamoDB base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('dynamodb'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/dynamodb/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/dynamodb/resources/table.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | DynamoDB.Table 16 | ~~~~~~~~~~~~~~ 17 | AWS DynamoDB Table interface 18 | """ 19 | # Third party imports 20 | from botocore.exceptions import ClientError, ParamValidationError 21 | 22 | # Cloudify 23 | from cloudify_aws.common import decorators, utils 24 | from cloudify_aws.dynamodb import DynamoDBBase 25 | 26 | RESOURCE_TYPE = 'DynamoDB Table' 27 | RESOURCE_NAME = 'TableName' 28 | 29 | 30 | class DynamoDBTable(DynamoDBBase): 31 | """ 32 | AWS DynamoDB Table interface 33 | """ 34 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 35 | DynamoDBBase.__init__(self, ctx_node, resource_id, client, logger) 36 | self.type_name = RESOURCE_TYPE 37 | 38 | @property 39 | def properties(self): 40 | """Gets the properties of an external resource""" 41 | if not self.resource_id: 42 | return 43 | resources = None 44 | try: 45 | resources = self.client.describe_table( 46 | TableName=self.resource_id) 47 | except (ParamValidationError, ClientError): 48 | pass 49 | if not resources or not resources.get('Table'): 50 | return None 51 | return resources['Table'] 52 | 53 | @property 54 | def status(self): 55 | """Gets the status of an external resource""" 56 | props = self.properties 57 | if props: 58 | return props.get('TableStatus') 59 | return None 60 | 61 | def create(self, params): 62 | """ 63 | Create a new AWS DynamoDB Table. 64 | """ 65 | return self.make_client_call('create_table', params) 66 | 67 | def delete(self, params=None): 68 | """ 69 | Deletes an existing AWS DynamoDB Table. 70 | """ 71 | self.logger.debug('Deleting %s with parameters: %s' 72 | % (self.type_name, params)) 73 | self.client.delete_table(**params) 74 | 75 | 76 | @decorators.aws_resource(DynamoDBTable, RESOURCE_TYPE) 77 | @decorators.wait_for_status(status_pending=['CREATING', 'UPDATING'], 78 | status_good=['ACTIVE']) 79 | @decorators.aws_params(RESOURCE_NAME) 80 | def create(ctx, iface, resource_config, params, **_): 81 | """Creates an AWS DynamoDB Table""" 82 | 83 | # Actually create the resource 84 | create_respose = iface.create(params) 85 | resource_id = create_respose['TableDescription']['TableName'] 86 | iface.update_resource_id(resource_id) 87 | utils.update_resource_id(ctx.instance, resource_id) 88 | utils.update_resource_arn( 89 | ctx.instance, create_respose['TableDescription']['TableArn']) 90 | 91 | 92 | @decorators.aws_resource(DynamoDBTable, RESOURCE_TYPE, 93 | ignore_properties=True) 94 | @decorators.wait_for_delete(status_pending=['DELETING']) 95 | def delete(iface, resource_config, **_): 96 | """Deletes an AWS DynamoDB Table""" 97 | # Add the required TableName parameter. 98 | if RESOURCE_NAME not in resource_config: 99 | resource_config.update({RESOURCE_NAME: iface.resource_id}) 100 | 101 | iface.delete(resource_config) 102 | -------------------------------------------------------------------------------- /cloudify_aws/dynamodb/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/dynamodb/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/dynamodb/tests/test_dynamodbbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.dynamodb import DynamoDBBase 20 | from cloudify_aws.common.tests.test_base import TestServiceBase 21 | 22 | 23 | class TestDynamoDBBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestDynamoDBBase, self).setUp() 27 | self.base = DynamoDBBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/decrypt.py: -------------------------------------------------------------------------------- 1 | # https://github.com/tomrittervg/decrypt-windows-ec2-passwd/blob/master/decrypt-windows-ec2-passwd.py 2 | 3 | import base64 4 | import binascii 5 | 6 | 7 | def pkcs1_unpad(text): 8 | # From http://kfalck.net/2011/03/07/decoding-pkcs1-padding-in-python 9 | if len(text) > 0 and text[0] == '\x02': 10 | # Find end of padding marked by nul 11 | pos = text.find('\x00') 12 | if pos > 0: 13 | return text[pos + 1:] 14 | return None 15 | 16 | 17 | def long_to_bytes(val, endianness='big'): 18 | # From http://stackoverflow.com/questions/8730927/ 19 | # convert-python-long-int-to-fixed-size-byte-array 20 | 21 | # one (1) hex digit per four (4) bits 22 | try: 23 | # Python < 2.7 doesn't have bit_length =( 24 | width = val.bit_length() 25 | except Exception: 26 | width = len(val.__hex__()[2:-1]) * 4 27 | 28 | # unhexlify wants an even multiple of eight (8) bits, but we don't 29 | # want more digits than we need (hence the ternary-ish 'or') 30 | width += 8 - ((width % 8) or 8) 31 | 32 | # format width specifier: four (4) bits per hex digit 33 | fmt = '%%0%dx' % (width // 4) 34 | 35 | # prepend zero (0) to the width, to zero-pad the output 36 | s = binascii.unhexlify(fmt % val) 37 | 38 | if endianness == 'little': 39 | # see http://stackoverflow.com/a/931095/309233 40 | s = s[::-1] 41 | 42 | return s 43 | 44 | 45 | def decrypt_password(rsa_key, password): 46 | # Undo the whatever-they-do to the ciphertext to get the integer 47 | encryptedData = base64.b64decode(password.encode('utf-8')) 48 | ciphertext = int(binascii.hexlify(encryptedData), 16) 49 | 50 | # Decrypt it 51 | plaintext = rsa_key.decrypt(ciphertext) 52 | 53 | # This is the annoying part. long -> byte array 54 | decryptedData = long_to_bytes(plaintext) 55 | # Now Unpad it 56 | unpaddedData = pkcs1_unpad(decryptedData) 57 | 58 | # Done 59 | return unpaddedData 60 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/resources/tags.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | EC2.Tags 16 | ~~~~~~~~~~~~~~ 17 | AWS EC2 Tags interface 18 | ''' 19 | # Cloudify 20 | from cloudify_aws.common.constants import EXTERNAL_RESOURCE_ID 21 | from cloudify_aws.common import decorators, utils 22 | from cloudify_aws.ec2 import EC2Base 23 | 24 | RESOURCE_TYPE = 'EC2 Tags' 25 | TAGS = 'Tags' 26 | 27 | 28 | class EC2Tags(EC2Base): 29 | ''' 30 | EC2 Tags interface 31 | ''' 32 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 33 | EC2Base.__init__(self, ctx_node, resource_id, client, logger) 34 | self.type_name = RESOURCE_TYPE 35 | self._describe_call = 'describe_tags' 36 | self._type_key = TAGS 37 | 38 | @property 39 | def properties(self): 40 | '''Gets the properties of an external resource''' 41 | if not self.resource_id: 42 | return {} 43 | params = {'Filters': [{'resource-id': self.resource_id}]} 44 | if not self._properties: 45 | self._properties = self.get_describe_result(params).get( 46 | self._type_key, [{}])[0] 47 | 48 | return self._properties 49 | 50 | @property 51 | def status(self): 52 | '''Gets the status of an external resource''' 53 | return None 54 | 55 | 56 | @decorators.aws_resource(EC2Tags, 57 | resource_type=RESOURCE_TYPE, 58 | waits_for_status=False) 59 | def prepare(ctx, iface, resource_config, **_): 60 | '''Prepares an AWS EC2 Vpc''' 61 | # Save the parameters 62 | ctx.instance.runtime_properties['resource_config'] = resource_config 63 | 64 | 65 | @decorators.aws_resource(EC2Tags, RESOURCE_TYPE, waits_for_status=False) 66 | def create(ctx, iface, resource_config, **_): 67 | '''Creates an AWS EC2 Tags''' 68 | resources = resource_config.get('Resources') 69 | if not resources: 70 | targets = \ 71 | utils.find_rels_by_type( 72 | ctx.instance, 73 | 'cloudify.relationships.depends_on') 74 | resources = \ 75 | [rel.target.instance.runtime_properties 76 | .get(EXTERNAL_RESOURCE_ID) for rel in targets] 77 | resource_config['Resources'] = resources 78 | 79 | # Actually create the resource 80 | create_response = iface.tag(resource_config) 81 | ctx.instance.runtime_properties['create_response'] = \ 82 | utils.JsonCleanuper(create_response).to_dict() 83 | 84 | 85 | @decorators.aws_resource(EC2Tags, RESOURCE_TYPE, waits_for_status=False) 86 | def delete(ctx, iface, resource_config, **_): 87 | '''Deletes an AWS EC2 Tags''' 88 | resources = resource_config.get('Resources') 89 | if not resources: 90 | targets = \ 91 | utils.find_rels_by_type( 92 | ctx.instance, 93 | 'cloudify.relationships.depends_on') 94 | resources = \ 95 | [rel.target.instance.runtime_properties 96 | .get(EXTERNAL_RESOURCE_ID) for rel in targets] 97 | resource_config['Resources'] = resources 98 | 99 | iface.untag(resource_config) 100 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/resources/vpn_connection_route.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | EC2.VPN Connection Route 16 | ~~~~~~~~~~~~~~ 17 | AWS EC2 VPN Connection Route interface 18 | """ 19 | from __future__ import unicode_literals 20 | 21 | # Cloudify 22 | from cloudify_aws.common import decorators, utils 23 | from cloudify_aws.ec2 import EC2Base 24 | 25 | 26 | RESOURCE_TYPE = 'EC2 VPN Connection Route' 27 | VPN_CONNECTION_ID = 'VpnConnectionId' 28 | DESTINATION_CIDR_BLOCK = 'DestinationCidrBlock' 29 | 30 | 31 | class EC2VPNConnectionRoute(EC2Base): 32 | """ 33 | EC2 VPN Connection Route interface 34 | """ 35 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 36 | EC2Base.__init__(self, ctx_node, resource_id, client, logger) 37 | self.type_name = RESOURCE_TYPE 38 | 39 | @property 40 | def properties(self): 41 | """Gets the properties of an external resource""" 42 | pass 43 | 44 | @property 45 | def status(self): 46 | """Gets the status of an external resource""" 47 | pass 48 | 49 | def create(self, params): 50 | """Create a new AWS EC2 VPN Connection Route.""" 51 | return self.make_client_call( 52 | 'create_vpn_connection_route', params) 53 | 54 | def delete(self, params=None): 55 | """ Deletes an existing AWS EC2 VPN Connection Route.""" 56 | self.client.delete_vpn_connection_route(**params) 57 | 58 | 59 | @decorators.aws_resource(EC2VPNConnectionRoute, resource_type=RESOURCE_TYPE) 60 | def prepare(ctx, resource_config, **_): 61 | """Prepares an AWS EC2 VPN Connection Route""" 62 | # Save the parameters 63 | ctx.instance.runtime_properties['resource_config'] = resource_config 64 | 65 | 66 | @decorators.aws_resource(EC2VPNConnectionRoute, RESOURCE_TYPE) 67 | def create(ctx, iface, resource_config, **_): 68 | """Creates an AWS EC2 VPN Connection Route""" 69 | resource_id = \ 70 | utils.get_resource_id( 71 | ctx.node, 72 | ctx.instance, 73 | resource_config.get(VPN_CONNECTION_ID), 74 | use_instance_id=True 75 | ) 76 | utils.update_resource_id(ctx.instance, resource_id) 77 | # Actually create the resource 78 | create_response = iface.create(resource_config) 79 | ctx.instance.runtime_properties['create_response'] = \ 80 | utils.JsonCleanuper(create_response).to_dict() 81 | ctx.instance.runtime_properties['VPN_CONNECTION_ID'] = \ 82 | resource_config.get(VPN_CONNECTION_ID) 83 | ctx.instance.runtime_properties['DESTINATION_CIDR_BLOCK'] = \ 84 | resource_config.get(DESTINATION_CIDR_BLOCK) 85 | 86 | 87 | @decorators.aws_resource(EC2VPNConnectionRoute, RESOURCE_TYPE) 88 | def delete(ctx, iface, resource_config, **_): 89 | """Deletes an AWS EC2 VPN Connection Route""" 90 | vpn_connection = ctx.instance.runtime_properties.get('VPN_CONNECTION_ID') 91 | cider_block = ctx.instance.runtime_properties.get('DESTINATION_CIDR_BLOCK') 92 | 93 | params = dict(VpnConnectionId=vpn_connection, 94 | DestinationCidrBlock=cider_block) \ 95 | if not resource_config else resource_config.copy() 96 | iface.delete(params) 97 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/ec2/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/ec2/tests/test_ec2.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | import mock 20 | 21 | from cloudify.exceptions import NonRecoverableError 22 | 23 | # Local imports 24 | from cloudify_aws.ec2 import EC2Base 25 | from cloudify_aws.common.constants import AWS_CONFIG_PROPERTY 26 | from cloudify_aws.common.tests.test_base import TestServiceBase 27 | 28 | 29 | class TestEC2Init(TestServiceBase): 30 | 31 | @mock.patch('cloudify_common_sdk.utils.get_ctx_instance') 32 | @mock.patch('cloudify_common_sdk.utils.get_ctx_plugin') 33 | def test_credentials(self, mock_plugin_ctx, *_): 34 | boto_client = mock.Mock() 35 | boto_mock = mock.Mock(return_value=boto_client) 36 | ctx_node = mock.Mock() 37 | ctx_node.properties = { 38 | AWS_CONFIG_PROPERTY: { 39 | 'region_name': 'wr-ongvalu-e' 40 | } 41 | } 42 | mock_plugin_ctx.return_value = { 43 | 'foo': 'bar' 44 | } 45 | with mock.patch( 46 | "cloudify_aws.ec2.Boto3Connection", boto_mock 47 | ): 48 | with self.assertRaises(NonRecoverableError): 49 | EC2Base(ctx_node) 50 | 51 | ctx_node.properties[AWS_CONFIG_PROPERTY] = { 52 | 'region_name': 'aq-testzone-1' 53 | } 54 | EC2Base(ctx_node) 55 | boto_mock.assert_called_with(ctx_node) 56 | boto_client.client.assert_called_with('ec2') 57 | 58 | 59 | if __name__ == '__main__': 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/tests/test_ec2base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.ec2 import EC2Base 21 | 22 | 23 | class TestEC2Base(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestEC2Base, self).setUp() 27 | self.base = EC2Base("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/tests/test_transit_gateway_route.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | from mock import patch, MagicMock 20 | 21 | # Local imports 22 | from cloudify_aws.common._compat import reload_module 23 | from cloudify_aws.common.tests.test_base import ( 24 | TestBase, 25 | mock_decorator 26 | ) 27 | from cloudify_aws.ec2.resources import transit_gateway_route as mod 28 | from cloudify_aws.ec2.resources.transit_gateway import TG_ATTACHMENT_ID 29 | from cloudify_aws.ec2.resources.transit_gateway_routetable import ROUTETABLE_ID 30 | 31 | 32 | class TestEC2TransitGatewayRoute(TestBase): 33 | 34 | def setUp(self): 35 | self.route = mod.EC2TransitGatewayRoute( 36 | "ctx_node", resource_id=True, 37 | client=True, logger=None) 38 | mock1 = patch('cloudify_aws.common.decorators.aws_resource', 39 | mock_decorator) 40 | mock1.start() 41 | reload_module(mod) 42 | 43 | def test_class_create(self): 44 | value = True 45 | config = {ROUTETABLE_ID: 'foo'} 46 | self.route.client = self.make_client_function( 47 | 'create_transit_gateway_route', return_value=value) 48 | res = self.route.create(config) 49 | self.assertEqual(True, res) 50 | 51 | def test_class_delete(self): 52 | params = {} 53 | self.route.client = self.make_client_function( 54 | 'delete_transit_gateway_route') 55 | self.route.delete(params) 56 | self.assertTrue(self.route.client.delete_transit_gateway_route.called) 57 | params = {ROUTETABLE_ID: 'foo'} 58 | self.route.delete(params) 59 | self.assertEqual(params[ROUTETABLE_ID], 'foo') 60 | 61 | def test_create(self): 62 | ctx = self.get_mock_ctx("RouteTable") 63 | config = { 64 | ROUTETABLE_ID: 'foo', 65 | TG_ATTACHMENT_ID: 'bar', 66 | 'DestinationCidrBlock': '0.0.0.0/0' 67 | } 68 | self.route.resource_id = config[ROUTETABLE_ID] 69 | iface = MagicMock() 70 | iface.create = self.mock_return(config) 71 | mod.create(ctx, iface, config) 72 | self.assertEqual(self.route.resource_id, 'foo') 73 | 74 | def test_delete(self): 75 | ctx = self.get_mock_ctx("RouteTable") 76 | iface = MagicMock() 77 | config = { 78 | ROUTETABLE_ID: 'route table', 79 | 'DestinationCidrBlock': '0.0.0.0/0' 80 | } 81 | mod.delete(ctx, iface, config) 82 | self.assertTrue(iface.delete.called) 83 | 84 | 85 | if __name__ == '__main__': 86 | unittest.main() 87 | -------------------------------------------------------------------------------- /cloudify_aws/ec2/tests/test_vpn_connection_route.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | from mock import patch, MagicMock 20 | 21 | # Local imports 22 | from cloudify_aws.common._compat import reload_module 23 | from cloudify_aws.common import constants 24 | from cloudify_aws.ec2.resources import vpn_connection_route 25 | from cloudify_aws.ec2.resources.vpn_connection_route\ 26 | import EC2VPNConnectionRoute 27 | from cloudify_aws.common.tests.test_base import ( 28 | TestBase, 29 | mock_decorator 30 | ) 31 | 32 | 33 | class TestEC2VPNConnectionRoute(TestBase): 34 | 35 | def setUp(self): 36 | super(TestEC2VPNConnectionRoute, self).setUp() 37 | self.vpn_connection_route =\ 38 | EC2VPNConnectionRoute("ctx_node", 39 | resource_id=True, 40 | client=True, logger=None) 41 | mock1 = patch('cloudify_aws.common.decorators.aws_resource', 42 | mock_decorator) 43 | mock1.start() 44 | reload_module(vpn_connection_route) 45 | 46 | def test_class_create(self): 47 | params = \ 48 | { 49 | 'DestinationCidrBlock': 'destination_cidr_block', 50 | 'VpnConnectionId': 'vpn_connection_id_test', 51 | } 52 | response = None 53 | 54 | self.vpn_connection_route.client = self.make_client_function( 55 | 'create_vpn_connection_route', return_value=response) 56 | self.assertEqual(self.vpn_connection_route.create(params), None) 57 | 58 | def test_class_delete(self): 59 | params = \ 60 | { 61 | 'DestinationCidrBlock': 'destination_cidr_block', 62 | 'VpnConnectionId': 'vpn_connection_id_test', 63 | } 64 | response = None 65 | 66 | self.vpn_connection_route.client = self.make_client_function( 67 | 'delete_vpn_connection_route', return_value=response) 68 | self.assertEqual(self.vpn_connection_route.delete(params), None) 69 | 70 | def test_prepare(self): 71 | ctx = self.get_mock_ctx("EC2VPNConnectionRoute") 72 | vpn_connection_route.prepare(ctx, 'config') 73 | self.assertEqual( 74 | ctx.instance.runtime_properties['resource_config'], 75 | 'config') 76 | 77 | def test_create(self): 78 | iface = MagicMock() 79 | ctx = self.get_mock_ctx("EC2VPNConnectionRoute") 80 | 81 | config = \ 82 | { 83 | 'DestinationCidrBlock': 'destination_cidr_block', 84 | 'VpnConnectionId': 'vpn_connection_id_test', 85 | } 86 | response = None 87 | iface.create = self.mock_return(response) 88 | vpn_connection_route.create(ctx, iface, config) 89 | self.assertEqual( 90 | ctx.instance.runtime_properties[constants.EXTERNAL_RESOURCE_ID], 91 | 'vpn_connection_id_test' 92 | ) 93 | 94 | def test_delete(self): 95 | iface = MagicMock() 96 | ctx = self.get_mock_ctx("EC2VPNConnectionRoute") 97 | vpn_connection_route.delete(ctx, iface, {}) 98 | self.assertTrue(iface.delete.called) 99 | 100 | 101 | if __name__ == '__main__': 102 | unittest.main() 103 | -------------------------------------------------------------------------------- /cloudify_aws/ecr/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | ECR 16 | ~~~ 17 | AWS ECR base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws_sdk.client import GenericAWSConnection 21 | 22 | 23 | class ECRBase(GenericAWSConnection): 24 | 25 | def __init__(self, 26 | ctx_node, 27 | resource_id=None, 28 | logger=None, 29 | **kwargs): 30 | kwargs.update({'service_name': 'ecr'}) 31 | super().__init__(**kwargs) 32 | self.ctx_node = ctx_node 33 | self.resource_id = resource_id 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def populate_resource(self, *_, **__): 46 | pass 47 | -------------------------------------------------------------------------------- /cloudify_aws/ecr/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/ecr/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/ecr/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/ecr/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/ecr/tests/test_auth_token.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Cloudify Platform LTD. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import mock 16 | from datetime import datetime 17 | 18 | from cloudify_aws.common.tests.test_base import TestBase 19 | from cloudify_aws.ecr.resources import authorization_token as auth 20 | 21 | 22 | def mock_aws_resource(function, 23 | class_decl, 24 | resource_type, 25 | ignore_properties, 26 | **kwargs): 27 | return function(**kwargs) 28 | 29 | 30 | DEFAULT_RC = { 31 | 'registryIds': [ 32 | 'foo', 33 | 'bar' 34 | ] 35 | } 36 | NODE_PROPERTIES = {'resource_config': DEFAULT_RC} 37 | DEFAULT_RUNTIME_PROPERTIES = {} 38 | TYPE_HIERARCHY = [ 39 | 'cloudify.nodes.Root', 40 | 'cloudify.nodes.aws.ecr.AuthenticationToken' 41 | ] 42 | 43 | 44 | @mock.patch('cloudify_aws.common.decorators._aws_resource', 45 | new=mock_aws_resource) 46 | class TestECRAuth(TestBase): 47 | 48 | def setUp(self, *_): 49 | with mock.patch('cloudify_aws_sdk.client.boto3'): 50 | with mock.patch('cloudify_aws_sdk.client.get_client_config'): 51 | self.auth = auth.ECRAuthorizationToken( 52 | mock.Mock(), 53 | resource_id=True, 54 | logger=None 55 | ) 56 | self.auth.client = mock.Mock() 57 | 58 | def test_prepare(self, *_): 59 | _ctx = self.get_mock_ctx( 60 | 'test_prepare', 61 | test_properties=NODE_PROPERTIES, 62 | test_runtime_properties=DEFAULT_RUNTIME_PROPERTIES, 63 | type_hierarchy=TYPE_HIERARCHY 64 | ) 65 | iface = mock.Mock() 66 | auth.prepare(ctx=_ctx, iface=iface, resource_config=DEFAULT_RC) 67 | self.assertIn('resource_config', _ctx.instance.runtime_properties) 68 | self.assertEqual( 69 | _ctx.instance.runtime_properties['resource_config'], 70 | DEFAULT_RC) 71 | iface.assert_not_called() 72 | 73 | def test_create(self, *_): 74 | _ctx = self.get_mock_ctx( 75 | 'test_create', 76 | test_properties=NODE_PROPERTIES, 77 | test_runtime_properties=DEFAULT_RUNTIME_PROPERTIES, 78 | type_hierarchy=TYPE_HIERARCHY 79 | ) 80 | iface = mock.Mock() 81 | auth.create(ctx=_ctx, iface=iface, resource_config=DEFAULT_RC) 82 | self.assertIn('create_response', _ctx.instance.runtime_properties) 83 | iface.create.assert_called_once() 84 | 85 | def test_class_create(self, *_): 86 | create_response = { 87 | 'authorizationData': [ 88 | { 89 | 'authorizationToken': 'foo', 90 | 'expiresAt': datetime(2015, 1, 1), 91 | 'proxyEndpoint': 'string' 92 | }, 93 | { 94 | 'authorizationToken': 'bar', 95 | 'expiresAt': datetime(2015, 1, 1), 96 | 'proxyEndpoint': 'string' 97 | }, 98 | ] 99 | } 100 | self.auth.client = self.make_client_function( 101 | 'get_authorization_token', return_value=create_response) 102 | self.assertEqual( 103 | self.auth.create(DEFAULT_RC), 104 | create_response 105 | ) 106 | -------------------------------------------------------------------------------- /cloudify_aws/ecs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | ECS 16 | ~~~ 17 | AWS ECS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | 24 | class ECSBase(AWSResourceBase): 25 | """ 26 | AWS ECS base interface 27 | """ 28 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 29 | AWSResourceBase.__init__( 30 | self, client or Boto3Connection(ctx_node).client('ecs'), 31 | resource_id=resource_id, logger=logger) 32 | 33 | @property 34 | def properties(self): 35 | """Gets the properties of an external resource""" 36 | raise NotImplementedError() 37 | 38 | @property 39 | def status(self): 40 | """Gets the status of an external resource""" 41 | raise NotImplementedError() 42 | 43 | def create(self, params): 44 | """Creates a resource""" 45 | raise NotImplementedError() 46 | 47 | def delete(self, params=None): 48 | """Deletes a resource""" 49 | raise NotImplementedError() 50 | -------------------------------------------------------------------------------- /cloudify_aws/ecs/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/ecs/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/ecs/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/ecs/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/efs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | EFS 16 | ~~~~~~~ 17 | AWS EFS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class EFSBase(AWSResourceBase): 27 | """ 28 | AWS EFS base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('efs'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/efs/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/efs/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/efs/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/efs/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/efs/tests/test_efs.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.efs import EFSBase 21 | 22 | 23 | class TestEFSBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestEFSBase, self).setUp() 27 | self.base = EFSBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/eks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018-2020 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | EKS 16 | ~~~ 17 | AWS EKS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | 24 | class EKSBase(AWSResourceBase): 25 | """ 26 | AWS EKS base interface 27 | """ 28 | 29 | service_name = 'eks' 30 | 31 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 32 | service = self.service_name 33 | AWSResourceBase.__init__( 34 | self, client or Boto3Connection(ctx_node).client(service), 35 | resource_id=resource_id, logger=logger) 36 | 37 | @property 38 | def properties(self): 39 | """Gets the properties of an external resource""" 40 | if not self._properties: 41 | res = self.describe() 42 | if self._type_key in res: 43 | if self._id_key in res[self._type_key]: 44 | if self.resource_id == res[self._type_key][self._id_key]: 45 | self._properties = res[self._type_key] 46 | return self._properties 47 | 48 | @property 49 | def status(self): 50 | """Gets the status of an external resource""" 51 | raise NotImplementedError() 52 | 53 | def create(self, params): 54 | """Creates a resource""" 55 | raise NotImplementedError() 56 | 57 | def delete(self, params=None): 58 | """Deletes a resource""" 59 | raise NotImplementedError() 60 | -------------------------------------------------------------------------------- /cloudify_aws/eks/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/eks/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/eks/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/eks/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/elb/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | ELB 16 | ~~~ 17 | AWS ELB base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class ELBBase(AWSResourceBase): 27 | """ 28 | AWS ELB base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('elb'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/elb/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/elb/resources/classic/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/elb/resources/classic/health_check.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | ELB.classic.health_check 16 | ~~~~~~~~~~~~ 17 | AWS ELB classic health check interface 18 | """ 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.elb import ELBBase 22 | from cloudify_aws.common.connection import Boto3Connection 23 | from cloudify_aws.common.constants import EXTERNAL_RESOURCE_ID 24 | 25 | RESOURCE_TYPE = 'ELB classic health check' 26 | LB_NAME = 'LoadBalancerName' 27 | LB_TYPE = 'cloudify.nodes.aws.elb.Classic.LoadBalancer' 28 | 29 | 30 | class ELBClassicHealthCheck(ELBBase): 31 | """ 32 | AWS ELB classic health check interface 33 | """ 34 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 35 | ELBBase.__init__( 36 | self, 37 | ctx_node, 38 | resource_id, 39 | client or Boto3Connection(ctx_node).client('elb'), 40 | logger) 41 | self.type_name = RESOURCE_TYPE 42 | 43 | @property 44 | def properties(self): 45 | """Gets the properties of an external resource""" 46 | return None 47 | 48 | @property 49 | def status(self): 50 | """Gets the status of an external resource""" 51 | props = self.properties 52 | if not props: 53 | return None 54 | 55 | # pylint: disable=E1136 56 | return props['State']['Code'] 57 | 58 | def create(self, params): 59 | """ 60 | Configure a new AWS ELB classic health check. 61 | .. note: 62 | See http://bit.ly/2p741nK for config details. 63 | """ 64 | return self.make_client_call('configure_health_check', params) 65 | 66 | def delete(self, params=None): 67 | return None 68 | 69 | 70 | @decorators.aws_resource(ELBClassicHealthCheck, 71 | RESOURCE_TYPE, 72 | waits_for_status=False) 73 | def prepare(ctx, resource_config, **_): 74 | """Prepares an ELB classic health check""" 75 | # Save the parameters 76 | ctx.instance.runtime_properties['resource_config'] = resource_config 77 | 78 | 79 | @decorators.aws_resource(ELBClassicHealthCheck, 80 | RESOURCE_TYPE, 81 | waits_for_status=False) 82 | def create(ctx, iface, resource_config, **_): 83 | """Creates an AWS ELB classic health check""" 84 | 85 | # Create a copy of the resource config for clean manipulation. 86 | params = utils.clean_params( 87 | dict() if not resource_config else resource_config.copy()) 88 | lb_name = params.get(LB_NAME) 89 | 90 | if not lb_name: 91 | targs = \ 92 | utils.find_rels_by_node_type( 93 | ctx.instance, 94 | LB_TYPE) 95 | lb_name = \ 96 | targs[0].target.instance.runtime_properties[ 97 | EXTERNAL_RESOURCE_ID] 98 | params.update({LB_NAME: lb_name}) 99 | 100 | ctx.instance.runtime_properties[LB_NAME] = lb_name 101 | 102 | # Actually create the resource 103 | iface.create(params) 104 | -------------------------------------------------------------------------------- /cloudify_aws/elb/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/elb/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/elb/tests/test_classic_health_check.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | from mock import patch, MagicMock 20 | 21 | # Local imports 22 | from cloudify_aws.common._compat import reload_module 23 | from cloudify_aws.common.constants import EXTERNAL_RESOURCE_ID 24 | from cloudify_aws.elb.resources.classic import health_check 25 | from cloudify_aws.common.tests.test_base import ( 26 | TestBase, 27 | mock_decorator 28 | ) 29 | from cloudify_aws.elb.resources.classic.health_check import ( 30 | ELBClassicHealthCheck, 31 | LB_NAME 32 | ) 33 | 34 | PATCH_PREFIX = 'cloudify_aws.elb.resources.classic.health_check.' 35 | 36 | 37 | class TestELBClassicHealthCheck(TestBase): 38 | 39 | def setUp(self): 40 | super(TestELBClassicHealthCheck, self).setUp() 41 | self.health_check = ELBClassicHealthCheck("ctx_node", resource_id=True, 42 | client=MagicMock(), 43 | logger=None) 44 | mock1 = patch('cloudify_aws.common.decorators.aws_resource', 45 | mock_decorator) 46 | mock1.start() 47 | reload_module(health_check) 48 | 49 | def test_class_properties(self): 50 | res = self.health_check.properties 51 | self.assertIsNone(res) 52 | 53 | def test_class_status(self): 54 | res = self.health_check.status 55 | self.assertIsNone(res) 56 | 57 | def test_class_create(self): 58 | value = {} 59 | self.health_check.client = self.make_client_function( 60 | 'configure_health_check', return_value='id') 61 | res = self.health_check.create(value) 62 | self.assertEqual(res, 'id') 63 | 64 | def test_class_delete(self): 65 | params = {} 66 | self.assertIsNone(self.health_check.delete(params)) 67 | 68 | def test_prepare(self): 69 | ctx = self.get_mock_ctx("ELB") 70 | health_check.prepare(ctx, 'config') 71 | self.assertEqual(ctx.instance.runtime_properties['resource_config'], 72 | 'config') 73 | 74 | def test_create(self): 75 | ctx = self.get_mock_ctx("ELB", {}, {'resource_config': {}}) 76 | ctx_target = self.get_mock_relationship_ctx( 77 | "elb", 78 | test_target=self.get_mock_ctx("elb", {}, 79 | {EXTERNAL_RESOURCE_ID: 'ext_id'})) 80 | iface = MagicMock() 81 | config = {LB_NAME: 'lb_name'} 82 | health_check.create(ctx, iface, config) 83 | self.assertTrue(iface.create.called) 84 | 85 | ctx = self.get_mock_ctx("ELB", {}, {'resource_config': {}}) 86 | config = {} 87 | with patch(PATCH_PREFIX + 'utils') as utils: 88 | utils.find_rels_by_node_type = self.mock_return([ctx_target]) 89 | health_check.create(ctx, iface, config) 90 | self.assertTrue(iface.create.called) 91 | 92 | 93 | if __name__ == '__main__': 94 | unittest.main() 95 | -------------------------------------------------------------------------------- /cloudify_aws/elb/tests/test_elbbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.elb import ELBBase 21 | 22 | 23 | class TestELBBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestELBBase, self).setUp() 27 | self.base = ELBBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/iam/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | IAM 16 | ~~~ 17 | AWS IAM base interface 18 | ''' 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | from cloudify_aws.common import utils 23 | from cloudify import ctx 24 | 25 | # pylint: disable=R0903 26 | ACCESS_KEY_CONFIGURE = 'cloudify_aws.iam.resources.access_key.configure' 27 | IAM_USER = 'cloudify.nodes.aws.iam.User' 28 | IAM_ACCESS = 'cloudify.nodes.aws.iam.AccessKey' 29 | 30 | 31 | class IAMBase(AWSResourceBase): 32 | ''' 33 | AWS IAM base interface 34 | ''' 35 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 36 | AWSResourceBase.__init__( 37 | self, client or Boto3Connection(ctx_node).client('iam'), 38 | resource_id=resource_id, logger=logger) 39 | 40 | if IAM_ACCESS in ctx_node.type_hierarchy: 41 | if (ctx.operation.name == ACCESS_KEY_CONFIGURE): 42 | targ = utils.find_rel_by_node_type(ctx.instance, IAM_USER) 43 | aws_config = targ.target.node.properties.get('client_config') 44 | boto3_connection = Boto3Connection(ctx_node, 45 | aws_config=aws_config) 46 | self.account_id = boto3_connection.get_account_id() 47 | else: 48 | self.account_id = Boto3Connection(ctx_node).get_account_id() 49 | 50 | @property 51 | def properties(self): 52 | '''Gets the properties of an external resource''' 53 | raise NotImplementedError() 54 | 55 | @property 56 | def status(self): 57 | '''Gets the status of an external resource''' 58 | raise NotImplementedError() 59 | 60 | def create(self, params): 61 | '''Creates a resource''' 62 | raise NotImplementedError() 63 | 64 | def delete(self, params=None): 65 | '''Deletes a resource''' 66 | raise NotImplementedError() 67 | -------------------------------------------------------------------------------- /cloudify_aws/iam/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/iam/resources/access_key.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | IAM.AccessKey 16 | ~~~~~~~~~~~~~ 17 | AWS IAM User Access Key 18 | ''' 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.iam.resources.user import IAMUser 22 | 23 | RESOURCE_TYPE = 'IAM User Access Key' 24 | 25 | 26 | @decorators.aws_resource(IAMUser, 27 | RESOURCE_TYPE, 28 | waits_for_status=False) 29 | def configure(ctx, resource_config, **_): 30 | '''Configures an AWS IAM Access Key''' 31 | # Save the parameters 32 | ctx.instance.runtime_properties['resource_config'] = \ 33 | utils.clean_params(resource_config) 34 | utils.update_resource_id( 35 | ctx.instance, utils.get_parent_resource_id( 36 | ctx.instance, 37 | 'cloudify.relationships.aws.iam.access_key.connected_to')) 38 | 39 | 40 | @decorators.aws_relationship(IAMUser, RESOURCE_TYPE) 41 | def attach_to(ctx, resource_config, **_): 42 | '''Attaches an IAM Access Key to something else''' 43 | rtprops = ctx.source.instance.runtime_properties 44 | if utils.is_node_type(ctx.target.node, 45 | 'cloudify.nodes.aws.iam.User'): 46 | resp = IAMUser( 47 | ctx.target.node, logger=ctx.logger, 48 | resource_id=utils.get_resource_id( 49 | node=ctx.target.node, 50 | instance=ctx.target.instance, 51 | raise_on_missing=True)).create_access_key( 52 | resource_config or rtprops.get('resource_config')) 53 | utils.update_resource_id(ctx.source.instance, resp['AccessKeyId']) 54 | ctx.source.instance.runtime_properties['SecretAccessKey'] = \ 55 | resp['SecretAccessKey'] 56 | 57 | 58 | @decorators.aws_relationship(IAMUser, RESOURCE_TYPE) 59 | def detach_from(ctx, resource_config, **_): 60 | '''Detaches an IAM Access Key from something else''' 61 | if utils.is_node_type(ctx.target.node, 62 | 'cloudify.nodes.aws.iam.User'): 63 | resource_config['AccessKeyId'] = utils.get_resource_id( 64 | node=ctx.source.node, 65 | instance=ctx.source.instance, 66 | raise_on_missing=True) 67 | IAMUser(ctx.target.node, 68 | logger=ctx.logger, 69 | resource_id=utils.get_resource_id( 70 | node=ctx.target.node, 71 | instance=ctx.target.instance, 72 | raise_on_missing=True)).delete_access_key(resource_config) 73 | -------------------------------------------------------------------------------- /cloudify_aws/iam/resources/login_profile.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | IAM.LoginProfile 16 | ~~~~~~~~~~~~~~~~ 17 | AWS IAM User Login Profile 18 | ''' 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.iam.resources.user import IAMUser 22 | 23 | RESOURCE_TYPE = 'IAM User Login Profile' 24 | 25 | 26 | @decorators.aws_resource(IAMUser, 27 | RESOURCE_TYPE, 28 | waits_for_status=False) 29 | def configure(ctx, resource_config, **_): 30 | '''Configures an AWS IAM Login Profile''' 31 | # Save the parameters 32 | ctx.instance.runtime_properties['resource_config'] = \ 33 | utils.clean_params(resource_config) 34 | utils.update_resource_id(ctx.instance, utils.get_parent_resource_id( 35 | ctx.instance, 36 | 'cloudify.relationships.aws.iam.login_profile.connected_to')) 37 | 38 | 39 | @decorators.aws_relationship(IAMUser, RESOURCE_TYPE) 40 | def attach_to(ctx, resource_config, **_): 41 | '''Attaches an IAM Login Profile to something else''' 42 | rtprops = ctx.source.instance.runtime_properties 43 | params = resource_config or rtprops.get('resource_config') or dict() 44 | if utils.is_node_type(ctx.target.node, 45 | 'cloudify.nodes.aws.iam.User'): 46 | IAMUser( 47 | ctx.target.node, logger=ctx.logger, 48 | resource_id=utils.get_resource_id( 49 | node=ctx.target.node, 50 | instance=ctx.target.instance, 51 | raise_on_missing=True)).create_login_profile(params) 52 | 53 | 54 | @decorators.aws_relationship(IAMUser, RESOURCE_TYPE) 55 | def detach_from(ctx, resource_config, **_): 56 | '''Detaches an IAM Login Profile from something else''' 57 | if utils.is_node_type(ctx.target.node, 58 | 'cloudify.nodes.aws.iam.User'): 59 | IAMUser( 60 | ctx.target.node, logger=ctx.logger, 61 | resource_id=utils.get_resource_id( 62 | node=ctx.target.node, 63 | instance=ctx.target.instance, 64 | raise_on_missing=True)).delete_login_profile(resource_config) 65 | -------------------------------------------------------------------------------- /cloudify_aws/iam/resources/role_policy.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | IAM.RolePolicy 16 | ~~~~~~~~~~ 17 | AWS IAM Role Policy interface 18 | ''' 19 | from json import dumps as json_dumps 20 | 21 | # Cloudify 22 | from cloudify_aws.common import decorators, utils, constants as CTS 23 | from cloudify_aws.iam import IAMBase 24 | 25 | RESOURCE_TYPE = 'IAM Role Policy' 26 | ROLE_NAME = 'RoleName' 27 | ROLE_TYPE = 'cloudify.nodes.aws.iam.Role' 28 | RESOURCE_NAME = 'PolicyName' 29 | 30 | 31 | class IAMRolePolicy(IAMBase): 32 | ''' 33 | AWS IAM Role Policy interface 34 | ''' 35 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 36 | IAMBase.__init__(self, ctx_node, resource_id, client, logger) 37 | self.type_name = RESOURCE_TYPE 38 | 39 | @property 40 | def properties(self): 41 | '''Gets the properties of an external resource''' 42 | return None 43 | 44 | @property 45 | def status(self): 46 | '''Gets the status of an external resource''' 47 | return None 48 | 49 | def create(self, params): 50 | ''' 51 | Create a new AWS IAM Role Policy. 52 | ''' 53 | return self.make_client_call('put_role_policy', params) 54 | 55 | def delete(self, params=None): 56 | ''' 57 | Deletes an existing AWS IAM Role Policy. 58 | ''' 59 | self.logger.debug('Deleting %s with parameters: %s' 60 | % (self.type_name, params)) 61 | res = self.client.delete_role_policy(**params) 62 | return res 63 | 64 | 65 | @decorators.aws_resource(IAMRolePolicy, RESOURCE_TYPE, waits_for_status=False) 66 | @decorators.aws_params(RESOURCE_NAME) 67 | def create(ctx, iface, resource_config, params, **_): 68 | '''Creates an AWS IAM Role Policy''' 69 | 70 | # Add RoleName 71 | role_name = params.get(ROLE_NAME, '') 72 | if not role_name: 73 | params[ROLE_NAME] = \ 74 | utils.find_resource_id_by_type( 75 | ctx.instance, 76 | ROLE_TYPE) 77 | if 'PolicyDocument' in params and \ 78 | isinstance(params['PolicyDocument'], dict): 79 | params['PolicyDocument'] = json_dumps(params['PolicyDocument']) 80 | 81 | # Actually create the resource 82 | iface.create(params) 83 | 84 | 85 | @decorators.aws_resource(IAMRolePolicy, 86 | RESOURCE_TYPE, 87 | ignore_properties=True, 88 | waits_for_status=False) 89 | def delete(ctx, iface, resource_config, **_): 90 | '''Deletes an AWS IAM Role Policy''' 91 | # Add RoleName 92 | role_name = resource_config.get(ROLE_NAME, '') 93 | if not role_name: 94 | resource_config[ROLE_NAME] = \ 95 | utils.find_resource_id_by_type( 96 | ctx.instance, 97 | ROLE_TYPE) 98 | # Add Policy Name 99 | policy_name = resource_config.get(RESOURCE_NAME, '') 100 | if not policy_name: 101 | resource_config[RESOURCE_NAME] = \ 102 | ctx.node.properties.get('resource_id') or \ 103 | ctx.instance.runtime_properties[CTS.EXTERNAL_RESOURCE_ID] or \ 104 | ctx.instance.id 105 | 106 | iface.delete(resource_config) 107 | -------------------------------------------------------------------------------- /cloudify_aws/iam/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/iam/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/iam/tests/test_iambase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | from mock import MagicMock 18 | 19 | # Local imports 20 | from cloudify_aws.iam import IAMBase 21 | from cloudify_aws.common.tests.test_base import TestServiceBase 22 | 23 | ctx_node = MagicMock( 24 | properties={}, 25 | plugin=MagicMock(properties={}) 26 | ) 27 | 28 | 29 | class TestIAMBase(TestServiceBase): 30 | 31 | def setUp(self): 32 | _ctx = MagicMock( # noqa 33 | node=ctx_node, 34 | plugin=MagicMock(properties={}) 35 | ) 36 | super(TestIAMBase, self).setUp() 37 | self.base = IAMBase( 38 | ctx_node, 39 | resource_id=True, 40 | client=True, 41 | logger=None 42 | ) 43 | 44 | 45 | if __name__ == '__main__': 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /cloudify_aws/kms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | KMS 16 | ~~~~~~~ 17 | AWS KMS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class KMSBase(AWSResourceBase): 27 | """ 28 | AWS KMS base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('kms'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/kms/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/kms/resources/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/kms/resources/alias.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | KMS.KeyAlias 16 | ~~~~~~~~ 17 | AWS KMS Key Alias interface 18 | """ 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.kms.resources.key import KMSKey 22 | from cloudify_aws.common.constants import EXTERNAL_RESOURCE_ID 23 | 24 | RESOURCE_TYPE = 'KMS Key Alias' 25 | RESOURCE_NAME = 'AliasName' 26 | TARGET_KEY_ID = 'TargetKeyId' 27 | KEY_TYPE = 'cloudify.nodes.aws.kms.CustomerMasterKey' 28 | 29 | 30 | class KMSKeyAlias(KMSKey): 31 | """ 32 | AWS KMS Key Alias interface 33 | """ 34 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 35 | KMSKey.__init__(self, ctx_node, resource_id, client, logger) 36 | self.type_name = RESOURCE_TYPE 37 | 38 | @property 39 | def properties(self): 40 | return None 41 | 42 | @property 43 | def status(self): 44 | """Gets the status of an external resource""" 45 | return None 46 | 47 | def create(self, params): 48 | """ 49 | Create a new AWS KMS Key Alias. 50 | """ 51 | return self.make_client_call('create_alias', params) 52 | 53 | def enable(self, params): 54 | return None 55 | 56 | def disable(self, params): 57 | return None 58 | 59 | def delete(self, params=None): 60 | """ 61 | Deletes an existing AWS KMS Key Alias. 62 | """ 63 | self.logger.debug('Deleting %s with parameters: %s' 64 | % (self.type_name, params)) 65 | self.client.delete_alias(**params) 66 | 67 | 68 | @decorators.aws_resource(KMSKeyAlias, RESOURCE_TYPE) 69 | def prepare(ctx, resource_config, **_): 70 | """Prepares an AWS KMS Key""" 71 | # Save the parameters 72 | ctx.instance.runtime_properties['resource_config'] = resource_config 73 | 74 | 75 | @decorators.aws_resource(KMSKeyAlias, RESOURCE_TYPE) 76 | def create(ctx, iface, resource_config, **_): 77 | """Creates an AWS KMS Key Alias""" 78 | resource_id = \ 79 | utils.get_resource_id( 80 | ctx.node, 81 | ctx.instance, 82 | resource_config.get(RESOURCE_NAME), 83 | use_instance_id=True 84 | ) 85 | resource_config[RESOURCE_NAME] = resource_id 86 | utils.update_resource_id(ctx.instance, resource_id) 87 | 88 | target_key_id = resource_config.get(TARGET_KEY_ID) 89 | if not target_key_id: 90 | target_key = \ 91 | utils.find_rel_by_node_type( 92 | ctx.instance, 93 | KEY_TYPE) 94 | target_key_id = \ 95 | target_key.target.instance.runtime_properties[EXTERNAL_RESOURCE_ID] 96 | resource_config[TARGET_KEY_ID] = target_key_id 97 | # Actually create the resource 98 | iface.create(resource_config) 99 | 100 | 101 | @decorators.aws_resource(KMSKeyAlias, RESOURCE_TYPE) 102 | def delete(ctx, iface, resource_config, **_): 103 | """Deletes an KMS Key Alias""" 104 | alias_name = resource_config.get(RESOURCE_NAME) 105 | if not alias_name: 106 | resource_config[RESOURCE_NAME] = \ 107 | ctx.instance.runtime_properties.get( 108 | EXTERNAL_RESOURCE_ID, 109 | iface.resource_id) 110 | 111 | # Actually delete the resource 112 | iface.delete(resource_config) 113 | -------------------------------------------------------------------------------- /cloudify_aws/kms/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/kms/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/kms/tests/test_kms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | from mock import patch, MagicMock 20 | 21 | from cloudify.state import current_ctx 22 | 23 | # Local imports 24 | from cloudify_aws.kms import KMSBase 25 | from cloudify_aws.common.tests.test_base import TestServiceBase 26 | from cloudify_aws.common.tests.test_base import TestBase, CLIENT_CONFIG 27 | from cloudify_aws.common.tests.test_base import DEFAULT_RUNTIME_PROPERTIES 28 | 29 | NODE_PROPERTIES = { 30 | 'use_external_resource': False, 31 | 'resource_config': {}, 32 | 'client_config': CLIENT_CONFIG 33 | } 34 | 35 | 36 | class TestKMSBase(TestServiceBase): 37 | 38 | def setUp(self): 39 | super(TestKMSBase, self).setUp() 40 | self.base = KMSBase("ctx_node", resource_id=True, 41 | client=True, logger=None) 42 | 43 | 44 | class TestKMS(TestBase): 45 | 46 | def setUp(self): 47 | super(TestKMS, self).setUp() 48 | 49 | self.fake_boto, self.fake_client = self.fake_boto_client('kms') 50 | self.mock_patch = patch('boto3.client', self.fake_boto) 51 | self.mock_patch.start() 52 | 53 | def tearDown(self): 54 | self.mock_patch.stop() 55 | self.fake_boto = None 56 | self.fake_client = None 57 | 58 | super(TestKMS, self).tearDown() 59 | 60 | def _prepare_context(self, type_hierarchy, node_prop=None, 61 | runtime_prop=None): 62 | 63 | mock_child = MagicMock() 64 | mock_child.type_hierarchy = 'cloudify.relationships.contained_in' 65 | mock_child.target.instance.runtime_properties = { 66 | 'aws_resource_id': 'a' 67 | } 68 | mock_child.target.node.type_hierarchy = [ 69 | 'cloudify.nodes.Root', 70 | 'cloudify.nodes.aws.kms.CustomerMasterKey' 71 | ] 72 | 73 | mock_child.target.node.id = 'aws-sample-node' 74 | mock_child.target.instance.relationships = [] 75 | 76 | _ctx = self.get_mock_ctx( 77 | 'test_create', 78 | test_properties=( 79 | node_prop if node_prop else NODE_PROPERTIES 80 | ), 81 | test_runtime_properties=( 82 | runtime_prop if runtime_prop else DEFAULT_RUNTIME_PROPERTIES 83 | ), 84 | type_hierarchy=type_hierarchy, 85 | test_relationships=[mock_child] 86 | ) 87 | 88 | current_ctx.set(_ctx) 89 | return _ctx 90 | 91 | 92 | if __name__ == '__main__': 93 | unittest.main() 94 | -------------------------------------------------------------------------------- /cloudify_aws/lambda_serverless/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | Lambda 16 | ~~~~~~ 17 | AWS Labmda base interface 18 | ''' 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class LambdaBase(AWSResourceBase): 27 | ''' 28 | AWS Lambda base interface 29 | ''' 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('lambda'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | '''Gets the properties of an external resource''' 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | '''Gets the status of an external resource''' 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | '''Creates a resource''' 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | '''Deletes a resource''' 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/lambda_serverless/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/lambda_serverless/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/lambda_serverless/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/lambda_serverless/tests/test_lambdabase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.lambda_serverless import LambdaBase 21 | 22 | 23 | class TestLambdaBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestLambdaBase, self).setUp() 27 | self.base = LambdaBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/rds/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | RDS 16 | ~~~ 17 | AWS RDS base interface 18 | ''' 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.utils import check_region_name 22 | from cloudify_common_sdk.utils import get_client_config 23 | from cloudify_aws.common.connection import Boto3Connection 24 | 25 | 26 | class RDSBase(AWSResourceBase): 27 | ''' 28 | AWS RDS base interface 29 | ''' 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | if not client: 32 | config_from_utils = get_client_config( 33 | ctx_node=ctx_node, alternate_key='aws_config') 34 | check_region_name(config_from_utils.get('region_name')) 35 | 36 | AWSResourceBase.__init__( 37 | self, client or Boto3Connection(ctx_node).client('rds'), 38 | resource_id=resource_id, logger=logger) 39 | 40 | @property 41 | def properties(self): 42 | '''Gets the properties of an external resource''' 43 | raise NotImplementedError() 44 | 45 | @property 46 | def status(self): 47 | '''Gets the status of an external resource''' 48 | raise NotImplementedError() 49 | 50 | def create(self, params): 51 | '''Creates a resource''' 52 | raise NotImplementedError() 53 | 54 | def delete(self, params=None): 55 | '''Deletes a resource''' 56 | raise NotImplementedError() 57 | -------------------------------------------------------------------------------- /cloudify_aws/rds/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/rds/resources/option.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | RDS.Option 16 | ~~~~~~~~~~ 17 | AWS RDS option interface 18 | ''' 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.rds.resources.option_group import OptionGroup 22 | 23 | RESOURCE_TYPE = 'RDS Option' 24 | SECGROUP_TYPE = 'cloudify.nodes.aws.ec2.SecurityGroup' 25 | SECGROUP_TYPE_DEPRECATED = 'cloudify.aws.nodes.SecurityGroup' 26 | 27 | 28 | @decorators.aws_resource(resource_type=RESOURCE_TYPE) 29 | def configure(ctx, resource_config, **_): 30 | '''Configures an AWS RDS Option''' 31 | # Save the parameters 32 | if resource_config.get('OptionName') and not utils.get_resource_id(): 33 | utils.update_resource_id(ctx.instance, resource_config['OptionName']) 34 | ctx.instance.runtime_properties['resource_config'] = resource_config 35 | 36 | 37 | @decorators.aws_relationship(resource_type=RESOURCE_TYPE) 38 | def attach_to(ctx, resource_config, **_): 39 | '''Attaches an RDS Option to something else''' 40 | rtprops = ctx.source.instance.runtime_properties 41 | params = resource_config or rtprops.get('resource_config') or dict() 42 | if utils.is_node_type(ctx.target.node, 43 | 'cloudify.nodes.aws.rds.OptionGroup'): 44 | params['OptionName'] = utils.get_resource_id( 45 | raise_on_missing=True, 46 | node=ctx.target.node, 47 | instance=ctx.target.instance 48 | ) 49 | OptionGroup( 50 | ctx.target.node, logger=ctx.logger, 51 | resource_id=utils.get_resource_id( 52 | node=ctx.target.node, 53 | instance=ctx.target.instance, 54 | raise_on_missing=True)).include_option(params) 55 | elif utils.is_node_type(ctx.target.node, SECGROUP_TYPE) or \ 56 | utils.is_node_type(ctx.target.node, SECGROUP_TYPE_DEPRECATED): 57 | security_groups = rtprops.get('resource_config').get( 58 | 'VpcSecurityGroupMemberships', list()) 59 | security_groups.append( 60 | utils.get_resource_id( 61 | node=ctx.target.node, 62 | instance=ctx.target.instance, 63 | raise_on_missing=True)) 64 | ctx.source.instance.runtime_properties[ 65 | 'resource_config']['VpcSecurityGroupMemberships'] = security_groups 66 | 67 | 68 | @decorators.aws_relationship(resource_type=RESOURCE_TYPE) 69 | def detach_from(ctx, resource_config, **_): 70 | '''Detaches an RDS Option from something else''' 71 | rtprops = ctx.source.instance.runtime_properties 72 | params = resource_config or rtprops.get('resource_config') or dict() 73 | if utils.is_node_type(ctx.target.node, 74 | 'cloudify.nodes.aws.rds.OptionGroup'): 75 | params['OptionName'] = utils.get_resource_id( 76 | raise_on_missing=True, 77 | node=ctx.target.node, 78 | instance=ctx.target.instance 79 | ) 80 | OptionGroup( 81 | ctx.target.node, logger=ctx.logger, 82 | resource_id=utils.get_resource_id( 83 | node=ctx.target.node, 84 | instance=ctx.target.instance, 85 | raise_on_missing=True)).remove_option(params) 86 | -------------------------------------------------------------------------------- /cloudify_aws/rds/resources/parameter.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | RDS.Parameter 16 | ~~~~~~~~~~~~~ 17 | AWS RDS parameter interface 18 | ''' 19 | # Cloudify 20 | from cloudify_aws.common import decorators, utils 21 | from cloudify_aws.rds.resources.parameter_group import ParameterGroup 22 | 23 | RESOURCE_TYPE = 'RDS Parameter' 24 | 25 | 26 | @decorators.aws_resource(resource_type=RESOURCE_TYPE, 27 | waits_for_status=False) 28 | def configure(ctx, resource_config, **_): 29 | '''Configures an AWS RDS Parameter''' 30 | # Save the parameters 31 | if resource_config.get('ParameterName') and not utils.get_resource_id(): 32 | utils.update_resource_id( 33 | ctx.instance, 34 | resource_config['ParameterName']) 35 | ctx.instance.runtime_properties['resource_config'] = resource_config 36 | 37 | 38 | @decorators.aws_relationship(resource_type=RESOURCE_TYPE) 39 | def attach_to(ctx, resource_config, **_): 40 | '''Attaches an RDS Parameter to something else''' 41 | rtprops = ctx.source.instance.runtime_properties 42 | params = resource_config or rtprops.get('resource_config') or dict() 43 | if utils.is_node_type(ctx.target.node, 44 | 'cloudify.nodes.aws.rds.ParameterGroup'): 45 | params['ParameterName'] = utils.get_resource_id( 46 | node=ctx.target.node, 47 | instance=ctx.target.instance, 48 | raise_on_missing=True 49 | ) 50 | ParameterGroup( 51 | ctx.target.node, logger=ctx.logger, 52 | resource_id=utils.get_resource_id( 53 | node=ctx.target.node, 54 | instance=ctx.target.instance, 55 | raise_on_missing=True)).update_parameter(params) 56 | 57 | 58 | @decorators.aws_relationship(resource_type=RESOURCE_TYPE) 59 | def detach_from(ctx, resource_config, **_): 60 | '''Detaches an RDS Parameter from something else''' 61 | pass 62 | -------------------------------------------------------------------------------- /cloudify_aws/rds/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /cloudify_aws/rds/tests/test_base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.rds import RDSBase 21 | 22 | 23 | class TestRDSBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestRDSBase, self).setUp() 27 | self.base = RDSBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/rds/tests/test_rds.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Third party imports 19 | import mock 20 | 21 | from cloudify.exceptions import NonRecoverableError 22 | 23 | # Local imports 24 | from cloudify_aws.rds import RDSBase 25 | from cloudify_aws.common.tests.test_base import TestServiceBase 26 | from cloudify_aws.common.constants import AWS_CONFIG_PROPERTY 27 | 28 | 29 | class TestRDSInit(TestServiceBase): 30 | 31 | @mock.patch('cloudify_common_sdk.utils.get_ctx_instance') 32 | @mock.patch('cloudify_common_sdk.utils.get_ctx_plugin') 33 | def test_credentials(self, mock_plugin_ctx, *_): 34 | boto_client = mock.Mock() 35 | boto_mock = mock.Mock(return_value=boto_client) 36 | ctx_node = mock.Mock() 37 | ctx_node.properties = { 38 | AWS_CONFIG_PROPERTY: { 39 | 'region_name': 'wr-ongvalu-e' 40 | } 41 | } 42 | mock_plugin_ctx.return_value = { 43 | 'foo': 'bar' 44 | } 45 | with mock.patch( 46 | "cloudify_aws.rds.Boto3Connection", boto_mock 47 | ): 48 | with self.assertRaises(NonRecoverableError): 49 | RDSBase(ctx_node) 50 | 51 | ctx_node.properties[AWS_CONFIG_PROPERTY] = { 52 | 'region_name': 'aq-testzone-1' 53 | } 54 | RDSBase(ctx_node) 55 | boto_mock.assert_called_with(ctx_node) 56 | boto_client.client.assert_called_with('rds') 57 | 58 | 59 | if __name__ == '__main__': 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /cloudify_aws/route53/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | ''' 15 | Route53 16 | ~~~~~~~ 17 | AWS Route53 base interface 18 | ''' 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class Route53Base(AWSResourceBase): 27 | ''' 28 | AWS Route53 base interface 29 | ''' 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('route53'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | '''Gets the properties of an external resource''' 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | '''Gets the status of an external resource''' 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | '''Creates a resource''' 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | '''Deletes a resource''' 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/route53/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/route53/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/route53/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/route53/tests/test_route53base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.route53 import Route53Base 21 | 22 | 23 | class TestRoute53Base(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestRoute53Base, self).setUp() 27 | self.base = Route53Base("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/s3/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | S3 16 | ~~~ 17 | AWS S3 base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | 24 | class S3Base(AWSResourceBase): 25 | """ 26 | AWS IAM base interface 27 | """ 28 | def __init__(self, ctx_node, aws_config=None, resource_id=None, 29 | client=None, logger=None): 30 | 31 | AWSResourceBase.__init__( 32 | self, 33 | client or Boto3Connection( 34 | ctx_node, 35 | aws_config 36 | ).client('s3'), 37 | resource_id=resource_id, logger=logger) 38 | 39 | @property 40 | def properties(self): 41 | """Gets the properties of an external resource""" 42 | raise NotImplementedError() 43 | 44 | @property 45 | def status(self): 46 | """Gets the status of an external resource""" 47 | raise NotImplementedError() 48 | 49 | def create(self, params): 50 | """Creates a resource""" 51 | raise NotImplementedError() 52 | 53 | def delete(self, params=None): 54 | """Deletes a resource""" 55 | raise NotImplementedError() 56 | -------------------------------------------------------------------------------- /cloudify_aws/s3/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/s3/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/s3/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/s3/tests/test_s3base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.s3 import S3Base 21 | 22 | 23 | class TestS3Base(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestS3Base, self).setUp() 27 | self.base = S3Base("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/sns/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | SNS 16 | ~~~~~~~ 17 | AWS SNS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class SNSBase(AWSResourceBase): 27 | """ 28 | AWS Route53 base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('sns'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/sns/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/sns/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/sns/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/sns/tests/test_snsbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.sns import SNSBase 21 | 22 | 23 | class TestSNSBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestSNSBase, self).setUp() 27 | self.base = SNSBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/sqs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | SQS 16 | ~~~~~~~ 17 | AWS SQS base interface 18 | """ 19 | # Cloudify AWS 20 | from cloudify_aws.common import AWSResourceBase 21 | from cloudify_aws.common.connection import Boto3Connection 22 | 23 | # pylint: disable=R0903 24 | 25 | 26 | class SQSBase(AWSResourceBase): 27 | """ 28 | AWS Route53 base interface 29 | """ 30 | def __init__(self, ctx_node, resource_id=None, client=None, logger=None): 31 | AWSResourceBase.__init__( 32 | self, client or Boto3Connection(ctx_node).client('sqs'), 33 | resource_id=resource_id, logger=logger) 34 | 35 | @property 36 | def properties(self): 37 | """Gets the properties of an external resource""" 38 | raise NotImplementedError() 39 | 40 | @property 41 | def status(self): 42 | """Gets the status of an external resource""" 43 | raise NotImplementedError() 44 | 45 | def create(self, params): 46 | """Creates a resource""" 47 | raise NotImplementedError() 48 | 49 | def delete(self, params=None): 50 | """Deletes a resource""" 51 | raise NotImplementedError() 52 | -------------------------------------------------------------------------------- /cloudify_aws/sqs/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # DO NOT REMOVE 2 | -------------------------------------------------------------------------------- /cloudify_aws/sqs/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/sqs/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/sqs/tests/test_sqsbase.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Standard imports 16 | import unittest 17 | 18 | # Local imports 19 | from cloudify_aws.common.tests.test_base import TestServiceBase 20 | from cloudify_aws.sqs import SQSBase 21 | 22 | 23 | class TestSQSBase(TestServiceBase): 24 | 25 | def setUp(self): 26 | super(TestSQSBase, self).setUp() 27 | self.base = SQSBase("ctx_node", resource_id=True, 28 | client=True, logger=None) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /cloudify_aws/workflows/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/workflows/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/workflows/check_status.py: -------------------------------------------------------------------------------- 1 | from contextlib import contextmanager 2 | 3 | from cloudify.decorators import operation 4 | 5 | from ..common import utils 6 | 7 | 8 | @operation 9 | def check_status(ctx, *_, **__): 10 | with node_interface(ctx) as interface: 11 | message = 'Resource {_id} of type {_type} is {status}'.format( 12 | _id=interface.resource_id, 13 | _type=interface.type_name, 14 | status=interface.check_status) 15 | if not interface.check_status.lower() == 'ok': 16 | raise RuntimeError(message) 17 | ctx.logger.info(message) 18 | 19 | 20 | @contextmanager 21 | def node_interface(ctx): 22 | if 'cloudify.nodes.aws.eks.Cluster' in ctx.node.type_hierarchy: 23 | from ..eks.resources import cluster as module 24 | yield initialize_node_interface(ctx, module.interface) 25 | elif 'cloudify.nodes.aws.eks.NodeGroup' in ctx.node.type_hierarchy: 26 | from ..eks.resources import node_group as module 27 | yield initialize_node_interface(ctx, module.interface) 28 | elif 'cloudify.nodes.aws.ec2.Vpc' in ctx.node.type_hierarchy: 29 | from ..ec2.resources import vpc as module 30 | yield initialize_node_interface(ctx, module.interface) 31 | elif 'cloudify.nodes.aws.ec2.Subnet' in ctx.node.type_hierarchy: 32 | from ..ec2.resources import subnet as module 33 | yield initialize_node_interface(ctx, module.interface) 34 | elif 'cloudify.nodes.aws.ec2.SecurityGroup' in ctx.node.type_hierarchy: 35 | from ..ec2.resources import securitygroup as module 36 | yield initialize_node_interface(ctx, module.interface) 37 | elif 'cloudify.nodes.aws.ec2.NATGateway' in ctx.node.type_hierarchy: 38 | from ..ec2.resources import nat_gateway as module 39 | yield initialize_node_interface(ctx, module.interface) 40 | elif 'cloudify.nodes.aws.ec2.Interface' in ctx.node.type_hierarchy: 41 | from ..ec2.resources import eni as module 42 | yield initialize_node_interface(ctx, module.interface) 43 | elif 'cloudify.nodes.aws.ec2.Instances' in ctx.node.type_hierarchy: 44 | from ..ec2.resources import instances as module 45 | yield initialize_node_interface(ctx, module.interface) 46 | elif 'cloudify.nodes.aws.ec2.ElasticIP' in ctx.node.type_hierarchy: 47 | from ..ec2.resources import elasticip as module 48 | yield initialize_node_interface(ctx, module.interface) 49 | elif 'cloudify.nodes.aws.ec2.InternetGateway' in ctx.node.type_hierarchy: 50 | from ..ec2.resources import internet_gateway as module 51 | yield initialize_node_interface(ctx, module.interface) 52 | elif 'cloudify.nodes.aws.ec2.RouteTable' in ctx.node.type_hierarchy: 53 | from ..ec2.resources import routetable as module 54 | yield initialize_node_interface(ctx, module.interface) 55 | else: 56 | ctx.logger.error( 57 | 'Check status is not supported on node type {_type}.'.format( 58 | _type=ctx.node.type_hierarchy[-1])) 59 | yield 60 | 61 | 62 | def initialize_node_interface(ctx, class_definition): 63 | module_init_kwargs = { 64 | 'ctx_node': ctx.node, 65 | 'logger': ctx.logger, 66 | 'resource_id': utils.get_resource_id( 67 | node=ctx.node, instance=ctx.instance), 68 | } 69 | return class_definition(**module_init_kwargs) 70 | -------------------------------------------------------------------------------- /cloudify_aws/workflows/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/cloudify_aws/workflows/tests/__init__.py -------------------------------------------------------------------------------- /cloudify_aws/workflows/tests/test_check_status.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | from contextlib import contextmanager 3 | from mock import patch, MagicMock 4 | 5 | from cloudify.mocks import MockCloudifyContext 6 | 7 | from .. import check_status 8 | 9 | 10 | class AWSCheckStatus(TestCase): 11 | 12 | def test_initialize(self, *_): 13 | ctx = MockCloudifyContext( 14 | "test_initialize", 15 | properties={ 16 | 'client_config': 'foo', 17 | }, 18 | runtime_properties={ 19 | 'aws_resource_id': 'foo', 20 | } 21 | ) 22 | result = check_status.initialize_node_interface(ctx, MagicMock) 23 | self.assertEqual(result.logger, ctx.logger) 24 | self.assertEqual(result.resource_id, 'foo') 25 | self.assertEqual(result.ctx_node, ctx.node) 26 | 27 | def test_node_interface_value_error(self, *_): 28 | ctx = MockCloudifyContext( 29 | "test_node_interface_value_error", 30 | properties={ 31 | 'client_config': 'foo', 32 | }, 33 | runtime_properties={ 34 | 'aws_resource_id': 'foo', 35 | } 36 | ) 37 | ctx.node.type_hierarchy = ['cloudify.nodes.aws.NotSupported'] 38 | with check_status.node_interface(ctx) as foo: 39 | self.assertIsNone(foo) 40 | 41 | @patch('cloudify_aws.eks.Boto3Connection') 42 | def test_node_interface(self, *_): 43 | ctx = MockCloudifyContext( 44 | "test_node_interface", 45 | properties={ 46 | 'client_config': 'foo', 47 | }, 48 | runtime_properties={ 49 | 'aws_resource_id': 'foo', 50 | } 51 | ) 52 | ctx.node.type_hierarchy = ['cloudify.nodes.aws.eks.Cluster'] 53 | with check_status.node_interface(ctx) as interface: 54 | self.assertEqual(interface.resource_id, 'foo') 55 | self.assertEqual(interface.logger, ctx.logger) 56 | 57 | def test_check_status(self, *_): 58 | ctx = MockCloudifyContext( 59 | "test_check_status", 60 | properties={ 61 | 'client_config': 'foo', 62 | }, 63 | runtime_properties={ 64 | 'aws_resource_id': 'foo', 65 | } 66 | ) 67 | tn = 'cloudify.nodes.aws.eks.Cluster' 68 | ctx.node.type_hierarchy = [tn] 69 | 70 | @contextmanager 71 | def mock_y(*args, **kwargs): 72 | interface_mock = MagicMock( 73 | resource_id='foo', type_name=tn, check_status='ok') 74 | yield interface_mock 75 | 76 | @contextmanager 77 | def mock_y_bad(*args, **kwargs): 78 | interface_mock = MagicMock( 79 | resource_id='foo', type_name=tn, check_status='not ok') 80 | yield interface_mock 81 | 82 | with patch('cloudify_aws.workflows.check_status.node_interface', 83 | mock_y): 84 | self.assertIsNone(check_status.check_status(ctx)) 85 | 86 | with patch('cloudify_aws.workflows.check_status.node_interface', 87 | mock_y_bad): 88 | with self.assertRaises(RuntimeError): 89 | check_status.check_status(ctx) 90 | -------------------------------------------------------------------------------- /cloudify_aws/workflows/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from mock import patch, call 2 | from unittest import TestCase 3 | 4 | from ...common import utils 5 | 6 | 7 | class AWSWorkflowUtilsTests(TestCase): 8 | 9 | def test_desecretize_client_config(self): 10 | expected = {'foo': 'bar'} 11 | result = utils.desecretize_client_config(expected) 12 | assert expected == result 13 | 14 | @patch('cloudify_aws.common.utils.get_rest_client') 15 | def test_with_rest_client(self, _): 16 | @utils.with_rest_client 17 | def mock_function(**kwargs): 18 | return kwargs 19 | self.assertIn('rest_client', mock_function()) 20 | 21 | @patch('cloudify_aws.common.utils.get_rest_client') 22 | def test_resolve_intrinsic_functions(self, mock_client): 23 | expected = 'foo' 24 | result = utils.resolve_intrinsic_functions(expected) 25 | assert expected == result 26 | prop = {'get_secret': 'bar'} 27 | utils.resolve_intrinsic_functions(prop) 28 | assert call().secrets.get('bar') in mock_client.mock_calls 29 | 30 | @patch('cloudify_aws.common.utils.get_rest_client') 31 | def test_get_secret(self, mock_client): 32 | prop = 'bar' 33 | utils.get_secret(secret_name=prop) 34 | assert call().secrets.get('bar') in mock_client.mock_calls 35 | 36 | @patch('cloudify_aws.common.utils.get_rest_client') 37 | def test_create_deployment(self, mock_client): 38 | prop = { 39 | 'group_id': 'bar', 40 | 'blueprint_id': 'foo', 41 | 'deployment_ids': ['foo'], 42 | 'inputs': [{'baz': 'taco'}], 43 | 'labels': [{'foo': 'bar'}], 44 | } 45 | utils.create_deployments(**prop) 46 | new_deployments = [{'display_name': 'foo', 'inputs': {'baz': 'taco'}}] 47 | labels = [{'foo': 'bar'}] 48 | assert call().deployment_groups.put( 49 | 'bar', 50 | 'foo', 51 | labels 52 | ) 53 | assert call().deployment_groups.add_deployments( 54 | 'bar', 55 | new_deployments=new_deployments, 56 | ) in mock_client.mock_calls 57 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/dev-requirements.txt -------------------------------------------------------------------------------- /examples/autoscaling-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | display_label: Aws Access Key Id 11 | type: string 12 | default: { get_secret: aws_access_key_id } 13 | 14 | aws_secret_access_key: 15 | display_label: Aws Secret Access Key 16 | type: string 17 | default: { get_secret: aws_secret_access_key } 18 | 19 | aws_region_name: 20 | display_label: Aws Region Name 21 | type: string 22 | default: eu-west-1 23 | 24 | instance_type: 25 | display_label: Instance Type 26 | type: string 27 | default: t2.micro 28 | 29 | dsl_definitions: 30 | 31 | client_config: &client_config 32 | aws_access_key_id: { get_input: aws_access_key_id } 33 | aws_secret_access_key: { get_input: aws_secret_access_key } 34 | aws_session_token: { get_secret: aws_session_token } 35 | region_name: { get_input: aws_region_name } 36 | 37 | node_templates: 38 | 39 | pmcfy_lh: 40 | type: cloudify.nodes.aws.autoscaling.LifecycleHook 41 | properties: 42 | resource_config: 43 | LifecycleHookName: pmcfy_lh 44 | LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING 45 | client_config: *client_config 46 | relationships: 47 | - type: cloudify.relationships.depends_on 48 | target: pmcfy_as 49 | 50 | pmcfy_asp: 51 | type: cloudify.nodes.aws.autoscaling.Policy 52 | properties: 53 | resource_config: 54 | PolicyName: pmcfy_asp 55 | PolicyType: SimpleScaling 56 | AdjustmentType: ChangeInCapacity 57 | ScalingAdjustment: 1 58 | client_config: *client_config 59 | relationships: 60 | - type: cloudify.relationships.depends_on 61 | target: pmcfy_as 62 | 63 | pmcfy_as: 64 | type: cloudify.nodes.aws.autoscaling.Group 65 | properties: 66 | resource_config: 67 | AutoScalingGroupName: pmcfy_as 68 | MinSize: 2 69 | MaxSize: 4 70 | kwargs: 71 | DesiredCapacity: 2 72 | DefaultCooldown: 20 73 | AvailabilityZones: 74 | - { concat: [ { get_input: aws_region_name }, 'a' ] } 75 | client_config: *client_config 76 | relationships: 77 | - type: cloudify.relationships.depends_on 78 | target: pmcfy_lc 79 | interfaces: 80 | cloudify.interfaces.lifecycle: 81 | delete: 82 | implementation: aws.cloudify_aws.autoscaling.resources.autoscaling_group.delete 83 | inputs: 84 | resource_config: 85 | ForceDelete: true 86 | 87 | pmcfy_lc: 88 | type: cloudify.nodes.aws.autoscaling.LaunchConfiguration 89 | properties: 90 | resource_config: 91 | LaunchConfigurationName: pmcfy_lc 92 | ImageId: { get_attribute: [ ami, aws_resource_id ] } 93 | InstanceType: { get_input: instance_type } 94 | client_config: *client_config 95 | relationships: 96 | - type: cloudify.relationships.depends_on 97 | target: ami 98 | 99 | ami: 100 | type: cloudify.nodes.aws.ec2.Image 101 | properties: 102 | resource_config: 103 | kwargs: 104 | Filters: 105 | - Name: name 106 | Values: 107 | - 'CentOS7-cloudify-examples-image' 108 | - Name: owner-id 109 | Values: 110 | - '263721492972' 111 | client_config: *client_config 112 | -------------------------------------------------------------------------------- /examples/autoscaling-feature-demo/test.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | availability_zone: 22 | type: string 23 | default: { concat: [ { get_input: aws_region_name}, 'c' ] } 24 | 25 | public_subnet_cidr: 26 | default: '10.0.0.0/24' 27 | 28 | vpc_cidr: 29 | default: '10.0.0.0/16' 30 | 31 | dsl_definitions: 32 | 33 | client_config: &client_config 34 | aws_access_key_id: { get_input: aws_access_key_id } 35 | aws_secret_access_key: { get_input: aws_secret_access_key } 36 | region_name: { get_input: aws_region_name } 37 | 38 | node_templates: 39 | 40 | autoscaling_lifecycle_hook: 41 | type: cloudify.nodes.aws.autoscaling.LifecycleHook 42 | properties: 43 | resource_config: 44 | LifecycleHookName: test-autoscaling 45 | LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING 46 | client_config: *client_config 47 | relationships: 48 | - type: cloudify.relationships.depends_on 49 | target: autoscaling_group 50 | 51 | autoscaling_group: 52 | type: cloudify.nodes.aws.autoscaling.Group 53 | properties: 54 | resource_config: 55 | AutoScalingGroupName: test-autoscaling 56 | MinSize: 1 57 | MaxSize: 2 58 | kwargs: 59 | DefaultCooldown: 300 60 | client_config: *client_config 61 | relationships: 62 | - type: cloudify.relationships.depends_on 63 | target: launch_configuration 64 | - type: cloudify.relationships.depends_on 65 | target: subnet 66 | 67 | launch_configuration: 68 | type: cloudify.nodes.aws.autoscaling.LaunchConfiguration 69 | properties: 70 | resource_config: 71 | LaunchConfigurationName: test-lauchconfig3 72 | client_config: *client_config 73 | relationships: 74 | - type: cloudify.relationships.depends_on 75 | target: instance 76 | 77 | instance: 78 | type: cloudify.nodes.aws.ec2.Instances 79 | properties: 80 | agent_config: 81 | install_method: none 82 | resource_config: 83 | MaxCount: 1 84 | MinCount: 1 85 | ImageId: { get_attribute: [ ubuntu_trusty_ami, aws_resource_id ] } 86 | InstanceType: t2.large 87 | client_config: *client_config 88 | relationships: 89 | - type: cloudify.relationships.depends_on 90 | target: subnet 91 | - type: cloudify.relationships.depends_on 92 | target: ubuntu_trusty_ami 93 | 94 | ubuntu_trusty_ami: 95 | type: cloudify.nodes.aws.ec2.Image 96 | properties: 97 | resource_config: 98 | kwargs: 99 | Filters: 100 | - Name: name 101 | Values: 102 | - 'ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20170727' 103 | - Name: owner-id 104 | Values: 105 | - '099720109477' 106 | client_config: *client_config 107 | 108 | subnet: 109 | type: cloudify.nodes.aws.ec2.Subnet 110 | properties: 111 | resource_config: 112 | CidrBlock: { get_input: public_subnet_cidr } 113 | AvailabilityZone: { get_input: availability_zone } 114 | client_config: *client_config 115 | relationships: 116 | - type: cloudify.relationships.depends_on 117 | target: vpc 118 | 119 | vpc: 120 | type: cloudify.nodes.aws.ec2.Vpc 121 | properties: 122 | resource_config: 123 | CidrBlock: { get_input: vpc_cidr } 124 | client_config: *client_config 125 | -------------------------------------------------------------------------------- /examples/autoscaling-feature-demo/variation.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | image_id: 22 | description: This AMI is matched to us-east-1. 23 | default: ami-e1496384 24 | 25 | dsl_definitions: 26 | 27 | client_config: &client_config 28 | aws_access_key_id: { get_input: aws_access_key_id } 29 | aws_secret_access_key: { get_input: aws_secret_access_key } 30 | region_name: { get_input: aws_region_name } 31 | 32 | node_templates: 33 | 34 | pmcfy_nc: 35 | type: cloudify.nodes.aws.autoscaling.NotificationConfiguration 36 | properties: 37 | client_config: *client_config 38 | resource_config: 39 | kwargs: 40 | NotificationTypes: 41 | - autoscaling:TEST_NOTIFICATION 42 | relationships: 43 | - type: cloudify.relationships.depends_on 44 | target: pmcfy_as 45 | - type: cloudify.relationships.depends_on 46 | target: pmcfy_topic 47 | 48 | pmcfy_as: 49 | type: cloudify.nodes.aws.autoscaling.Group 50 | properties: 51 | resource_config: 52 | kwargs: 53 | AutoScalingGroupName: pmcfy_as 54 | MinSize: 1 55 | MaxSize: 1 56 | DefaultCooldown: 300 57 | AvailabilityZones: 58 | - { concat: [ { get_input: aws_region_name }, 'a' ] } 59 | client_config: *client_config 60 | relationships: 61 | - type: cloudify.relationships.depends_on 62 | target: pmcfy_lc 63 | interfaces: 64 | cloudify.interfaces.lifecycle: 65 | delete: 66 | implementation: aws.cloudify_aws.autoscaling.resources.autoscaling_group.delete 67 | inputs: 68 | resource_config: 69 | ForceDelete: true 70 | 71 | pmcfy_lc: 72 | type: cloudify.nodes.aws.autoscaling.LaunchConfiguration 73 | properties: 74 | resource_config: 75 | kwargs: 76 | ImageId: { get_input: image_id } 77 | InstanceType: t2.micro 78 | LaunchConfigurationName: pmcfy_lc 79 | client_config: *client_config 80 | 81 | pmcfy_topic: 82 | type: cloudify.nodes.aws.SNS.Topic 83 | properties: 84 | resource_config: 85 | kwargs: 86 | Name: pmcfy_topic 87 | client_config: *client_config 88 | -------------------------------------------------------------------------------- /examples/cloudformation-feature-demo/rds-stack.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | region_name: { get_input: aws_region_name } 27 | 28 | node_templates: 29 | 30 | mydb: 31 | type: cloudify.nodes.aws.CloudFormation.Stack 32 | properties: 33 | resource_id: { concat: [ { get_input: aws_region_name }, cfntest ] } 34 | client_config: *client_config 35 | resource_config: 36 | kwargs: 37 | StackName: cfntest0 38 | TemplateBody: 39 | AWSTemplateFormatVersion: "2010-09-09" 40 | Description: A sample template 41 | Outputs: 42 | MyDBEndpointAddress: 43 | Description: The RDS Instance address. 44 | Value: 45 | Fn::GetAtt: [MyDB, Endpoint.Address] 46 | MyDBEndpointPort: 47 | Description: The RDS Instance port. 48 | Value: 49 | Fn::GetAtt: [MyDB, Endpoint.Port] 50 | Resources: 51 | MyDB: 52 | Type: "AWS::RDS::DBInstance" 53 | Properties: 54 | AllocatedStorage: "100" 55 | DBInstanceClass: "db.m1.small" 56 | Engine: "MySQL" 57 | EngineVersion: "5.5" 58 | Iops: "1000" 59 | MasterUsername: MyUser 60 | MasterUserPassword: MyPassword 61 | DeletionPolicy: "Snapshot" 62 | 63 | outputs: 64 | 65 | Endpoint: 66 | value: 67 | concat: 68 | - { get_attribute: [ mydb, Outputs, 0, OutputValue ] } 69 | - ':' 70 | - { get_attribute: [ mydb, Outputs, 1, OutputValue ] } 71 | -------------------------------------------------------------------------------- /examples/codepipeline-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | description: > 4 | Example blueprint showing AWS Codepipeline functionality. 5 | 6 | imports: 7 | - cloudify/types/types.yaml 8 | - plugin:cloudify-aws-plugin 9 | 10 | 11 | inputs: 12 | 13 | aws_region_name: 14 | type: string 15 | default: 'eu-west-1' 16 | 17 | pipeline_name: 18 | type: string 19 | default: 'Demopipeline' 20 | 21 | code_pipeline_service_role: 22 | type: string 23 | 24 | artifact_store_bucket_name: 25 | type: string 26 | 27 | source_code_bucket: 28 | type: string 29 | 30 | deployment_bucket_name: 31 | type: string 32 | 33 | dsl_definitions: 34 | client_config: &client_config 35 | aws_access_key_id: { get_secret: aws_access_key_id } 36 | aws_secret_access_key: { get_secret: aws_secret_access_key } 37 | region_name: { get_input: aws_region_name } 38 | 39 | node_templates: 40 | 41 | codepipeline: 42 | type: cloudify.nodes.aws.codepipeline.Pipeline 43 | properties: 44 | client_config: *client_config 45 | resource_config: 46 | kwargs: 47 | pipeline: 48 | name: { get_input: pipeline_name } 49 | roleArn: { get_input: code_pipeline_service_role } 50 | artifactStore: 51 | type: 'S3' 52 | location: { get_input: artifact_store_bucket_name } 53 | stages: 54 | - name: 'Source-stage' 55 | actions: 56 | - name: 'source-action' 57 | actionTypeId: 58 | category: 'Source' 59 | owner: 'AWS' 60 | provider: 'S3' 61 | version: '1' 62 | outputArtifacts: 63 | - name: 'My-source' 64 | configuration: 65 | S3Bucket: { get_input: source_code_bucket } 66 | S3ObjectKey: test-app.zip 67 | PollForSourceChanges: 'false' 68 | region: { get_input: aws_region_name } 69 | - name: 'Deploy-stage' 70 | actions: 71 | - name: 'deploy-action' 72 | actionTypeId: 73 | category: 'Deploy' 74 | owner: 'AWS' 75 | provider: 'S3' 76 | version: '1' 77 | inputArtifacts: 78 | - name: 'My-source' 79 | configuration: 80 | "BucketName": { get_input: deployment_bucket_name } 81 | "Extract": "true" 82 | region: { get_input: aws_region_name } 83 | version: 1 84 | -------------------------------------------------------------------------------- /examples/dynamodb-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | description: > 4 | Example blueprint showing AWS DynamoDB functionality. 5 | 6 | imports: 7 | - cloudify/types/types.yaml 8 | - plugin:cloudify-aws-plugin 9 | 10 | inputs: 11 | 12 | aws_access_key_id: 13 | display_label: Aws Access Key Id 14 | type: string 15 | default: { get_secret: aws_access_key_id } 16 | 17 | aws_secret_access_key: 18 | display_label: Aws Secret Access Key 19 | type: string 20 | default: { get_secret: aws_secret_access_key } 21 | 22 | aws_region_name: 23 | display_label: Aws Region Name 24 | type: string 25 | default: { get_secret: ec2_region_name } 26 | 27 | dsl_definitions: 28 | 29 | client_config: &client_config 30 | aws_access_key_id: { get_input: aws_access_key_id } 31 | aws_secret_access_key: { get_input: aws_secret_access_key } 32 | aws_session_token: { get_secret: aws_session_token } 33 | region_name: { get_input: aws_region_name } 34 | 35 | node_templates: 36 | 37 | dynamodb_table: 38 | type: cloudify.nodes.aws.dynamodb.Table 39 | properties: 40 | client_config: *client_config 41 | resource_config: 42 | TableName: !!str abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.0123456789 43 | AttributeDefinitions: 44 | - AttributeName: RandomKeyUUID 45 | AttributeType: S 46 | KeySchema: 47 | - AttributeName: RandomKeyUUID 48 | KeyType: HASH 49 | ProvisionedThroughput: 50 | ReadCapacityUnits: 5 51 | WriteCapacityUnits: 5 52 | -------------------------------------------------------------------------------- /examples/ebs-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | description: YOUR AWS ACCESS KEY ID 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | description: YOUR AWS SECRET ACCESS KEY 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | default: { get_secret: aws_region_name } 19 | 20 | availability_zone: 21 | default: { concat: [ { get_input: aws_region_name }, 'a' ] } 22 | 23 | dsl_definitions: 24 | 25 | client_config: &client_config 26 | aws_access_key_id: { get_input: aws_access_key_id } 27 | aws_secret_access_key: { get_input: aws_secret_access_key } 28 | aws_session_token: { get_secret: aws_session_token } 29 | region_name: { get_input: aws_region_name } 30 | 31 | node_templates: 32 | 33 | ebs_volume: 34 | type: cloudify.nodes.aws.ec2.EBSVolume 35 | properties: 36 | resource_config: 37 | AvailabilityZone: { get_input: availability_zone } 38 | Size: 6 39 | kwargs: 40 | TagSpecifications: 41 | - ResourceType: volume 42 | Tags: 43 | - Key: First 44 | Value: First Volume 45 | - Key: Second 46 | Value: Second Volume 47 | client_config: *client_config 48 | -------------------------------------------------------------------------------- /examples/ec2-image-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | ami_owner_filter: 22 | type: string 23 | description: The AWS AMI owner number. 24 | default: '263721492972' 25 | 26 | ami_name_filter: 27 | type: string 28 | description: The name of the AWS AMI in the AWS region. 29 | default: 'CentOS7-cloudify-examples-image' 30 | 31 | dsl_definitions: 32 | 33 | client_config: &client_config 34 | aws_access_key_id: { get_input: aws_access_key_id } 35 | aws_secret_access_key: { get_input: aws_secret_access_key } 36 | aws_session_token: { get_secret: aws_session_token } 37 | region_name: { get_input: aws_region_name } 38 | 39 | node_templates: 40 | 41 | cloudify_manager_ami: 42 | type: cloudify.nodes.aws.ec2.Image 43 | properties: 44 | resource_config: 45 | kwargs: 46 | Filters: 47 | - Name: name 48 | Values: 49 | - { get_input: ami_name_filter } 50 | - Name: owner-id 51 | Values: 52 | - { get_input: ami_owner_filter } 53 | client_config: *client_config 54 | -------------------------------------------------------------------------------- /examples/ec2-instance-feature-demo/eip-nic-blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | imports: 3 | - cloudify/types/types.yaml 4 | - plugin:cloudify-aws-plugin 5 | inputs: 6 | aws_access_key_id: 7 | type: string 8 | description: YOUR AWS ACCESS KEY ID 9 | default: { get_secret: aws_access_key_id } 10 | aws_secret_access_key: 11 | type: string 12 | description: YOUR AWS SECRET ACCESS KEY 13 | default: { get_secret: aws_secret_access_key } 14 | region_name: 15 | type: string 16 | description: YOUR AWS Region 17 | default: { get_secret: aws_region_name } 18 | ec2_region_endpoint: 19 | type: string 20 | description: YOUR AWS Region endpoint 21 | default: { get_secret: ec2_region_endpoint } 22 | availability_zone: 23 | type: string 24 | description: Your AWS Region availability_zone. 25 | default: { get_secret: aws_availability_zone } 26 | use_external_ip: 27 | type: boolean 28 | default: False 29 | existing_ip: 30 | type: string 31 | default: '' 32 | subnet_id: 33 | type: string 34 | dsl_definitions: 35 | client_config: &client_config 36 | aws_access_key_id: { get_input: aws_access_key_id } 37 | aws_secret_access_key: { get_input: aws_secret_access_key } 38 | region_name: { get_input: aws_region_name } 39 | node_templates: 40 | nic: 41 | type: cloudify.nodes.aws.ec2.Interface 42 | properties: 43 | client_config: *client_config 44 | resource_config: 45 | kwargs: 46 | Description: Test EIP/NICs. 47 | SubnetId: { get_input: subnet_id } 48 | eip: 49 | type: cloudify.nodes.aws.ec2.ElasticIP 50 | properties: 51 | client_config: *client_config 52 | use_external_resource: { get_input: use_external_ip } 53 | resource_id: { get_input: existing_ip } 54 | relationships: 55 | - type: cloudify.relationships.depends_on 56 | target: nic 57 | outputs: 58 | nic_id: 59 | value: { get_attribute: [ nic, aws_resource_id ] } 60 | eip_id: 61 | value: { get_attribute: [ eip, aws_resource_id ] } 62 | -------------------------------------------------------------------------------- /examples/ec2-instance-feature-demo/elastic-ip.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | description: YOUR AWS ACCESS KEY ID 11 | # default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | description: YOUR AWS SECRET ACCESS KEY 15 | # default: { get_secret: aws_secret_access_key } 16 | 17 | ec2_region_name: 18 | description: YOUR AWS Region 19 | # default: { get_secret: ec2_region_name } 20 | 21 | ec2_region_endpoint: 22 | description: YOUR AWS Region endpoint 23 | # default: { get_secret: ec2_region_endpoint } 24 | 25 | availability_zone: 26 | default: Your AWS Region availability_zone. 27 | # default: { get_secret: availability_zone } 28 | 29 | existing_ip: 30 | type: string 31 | 32 | dsl_definitions: 33 | 34 | client_config: &client_config 35 | aws_access_key_id: { get_input: aws_access_key_id } 36 | aws_secret_access_key: { get_input: aws_secret_access_key } 37 | region_name: { get_input: ec2_region_name } 38 | 39 | node_templates: 40 | 41 | ip: 42 | type: cloudify.nodes.aws.ec2.ElasticIP 43 | properties: 44 | use_external_resource: true 45 | resource_id: { get_input: existing_ip } 46 | resource_config: 47 | kwargs: 48 | Domain: 'vpc' 49 | client_config: *client_config 50 | -------------------------------------------------------------------------------- /examples/ec2-keys-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | description: YOUR AWS ACCESS KEY ID 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | description: YOUR AWS SECRET ACCESS KEY 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: aws_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | aws_session_token: { get_secret: aws_session_token } 27 | region_name: { get_input: aws_region_name } 28 | 29 | node_templates: 30 | 31 | my_key: 32 | type: cloudify.nodes.aws.ec2.Keypair 33 | properties: 34 | store_in_runtime_properties: true 35 | client_config: *client_config 36 | 37 | -------------------------------------------------------------------------------- /examples/ec2-vpc-feature-demo/acl.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | region_name: { get_input: aws_region_name } 27 | 28 | node_templates: 29 | 30 | vpc_requester: 31 | type: cloudify.nodes.aws.ec2.Vpc 32 | properties: 33 | resource_config: 34 | CidrBlock: '10.0.0.0/16' 35 | client_config: *client_config 36 | 37 | subnet_vpc_requster: 38 | type: cloudify.nodes.aws.ec2.Subnet 39 | properties: 40 | resource_config: 41 | CidrBlock: '10.0.0.0/24' 42 | client_config: *client_config 43 | relationships: 44 | - type: cloudify.relationships.depends_on 45 | target: vpc_requester 46 | 47 | subnet_vpc_requster1: 48 | type: cloudify.nodes.aws.ec2.Subnet 49 | properties: 50 | resource_config: 51 | CidrBlock: '10.0.1.0/24' 52 | client_config: *client_config 53 | relationships: 54 | - type: cloudify.relationships.depends_on 55 | target: vpc_requester 56 | 57 | subnet_vpc_requster2: 58 | type: cloudify.nodes.aws.ec2.Subnet 59 | properties: 60 | resource_config: 61 | CidrBlock: '10.0.2.0/24' 62 | client_config: *client_config 63 | relationships: 64 | - type: cloudify.relationships.depends_on 65 | target: vpc_requester 66 | 67 | network_acl_vpc_requster: 68 | type: cloudify.nodes.aws.ec2.NetworkACL 69 | properties: 70 | client_config: *client_config 71 | relationships: 72 | - type: cloudify.relationships.contained_in 73 | target: vpc_requester 74 | - type: cloudify.relationships.connected_to 75 | target: subnet_vpc_requster1 76 | - type: cloudify.relationships.connected_to 77 | target: subnet_vpc_requster2 78 | -------------------------------------------------------------------------------- /examples/ec2-vpc-feature-demo/test.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | aws_vpc_id: 22 | default: { get_secret: vpc_id } 23 | 24 | openstack_public_ip: 25 | type: string 26 | 27 | dsl_definitions: 28 | 29 | client_config: &client_config 30 | aws_access_key_id: { get_input: aws_access_key_id } 31 | aws_secret_access_key: { get_input: aws_secret_access_key } 32 | region_name: { get_input: aws_region_name } 33 | 34 | node_templates: 35 | 36 | exists_vpc: 37 | type: cloudify.nodes.aws.ec2.Vpc 38 | properties: 39 | client_config: *client_config 40 | use_external_resource: true 41 | resource_id: { get_input: aws_vpc_id} 42 | 43 | vpn_gateway_one: 44 | type: cloudify.nodes.aws.ec2.VPNGateway 45 | properties: 46 | resource_config: 47 | kwargs: 48 | Type: 'ipsec.1' 49 | client_config: *client_config 50 | relationships: 51 | - type: cloudify.relationships.connected_to 52 | target: exists_vpc 53 | 54 | customer_gateway_one: 55 | type: cloudify.nodes.aws.ec2.CustomerGateway 56 | properties: 57 | resource_config: 58 | kwargs: 59 | Type: 'ipsec.1' 60 | PublicIp: { get_input: openstack_public_ip} 61 | BgpAsn: 65000 62 | client_config: *client_config 63 | relationships: 64 | - type: cloudify.relationships.connected_to 65 | target: exists_vpc 66 | 67 | vpn_connection_vpc_requster: 68 | type: cloudify.nodes.aws.ec2.VPNConnection 69 | properties: 70 | client_config: *client_config 71 | interfaces: 72 | cloudify.interfaces.lifecycle: 73 | create: 74 | inputs: 75 | resource_config: 76 | CustomerGatewayId: { get_attribute: [customer_gateway_one, aws_resource_id] } 77 | Type: 'ipsec.1' 78 | VpnGatewayId: { get_attribute: [vpn_gateway_one, aws_resource_id] } 79 | Options: 80 | StaticRoutesOnly: False 81 | relationships: 82 | - type: cloudify.relationships.depends_on 83 | target: vpn_gateway_one 84 | - type: cloudify.relationships.depends_on 85 | target: customer_gateway_one 86 | -------------------------------------------------------------------------------- /examples/ecr-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | description: Generate Tokens and Create Repository 4 | 5 | imports: 6 | - cloudify/types/types.yaml 7 | - plugin:cloudify-aws-plugin: 8 | aws_access_key_id: { get_secret: aws_access_key_id } 9 | aws_secret_access_key: { get_secret: aws_secret_access_key } 10 | region_name: us-east-2 11 | 12 | inputs: 13 | 14 | registry_id: 15 | type: string 16 | description: Account ID associated with an ECR registry. 17 | 18 | repo_name: 19 | type: string 20 | description: The name of a repo. 21 | 22 | node_templates: 23 | 24 | token: 25 | type: cloudify.nodes.aws.ecr.AuthenticationToken 26 | properties: 27 | resource_config: 28 | registryIds: 29 | - { get_input: registry_id } 30 | 31 | repo: 32 | type: cloudify.nodes.aws.ecr.Repository 33 | properties: 34 | resource_config: 35 | registryId: { get_input: registry_id } 36 | repositoryName: { get_input: repo_name } 37 | tags: 38 | - Key: created-by 39 | Value: ecr-feature-demo 40 | imageTagMutability: MUTABLE 41 | imageScanningConfiguration: 42 | scanOnPush: true 43 | encryptionConfiguration: 44 | encryptionType: AES256 45 | -------------------------------------------------------------------------------- /examples/eks-feature-demo/README.md: -------------------------------------------------------------------------------- 1 | # Amazon EKS Example 2 | 3 | ## Prerequisites: 4 | 5 | * Cloudify Manager with Latest AWS and Kubernetes Plugins. 6 | 7 | ### Creating secrets 8 | 9 | Create secrets according to your AWS credentials. 10 | and name of already created keypair 11 | 12 | Replace with actual values, without the <> 13 | 14 | ```shell 15 | cfy secrets create aws_access_key_id --secret-string 16 | cfy secrets create aws_secret_access_key --secret-string 17 | cfy secrets create aws_keypair --secret-string 18 | ``` 19 | 20 | 21 | ### Running the example 22 | 23 | ```shell 24 | cfy install blueprint.yaml -i eks_cluster_name=eks_cluster -i eks_nodegroup_name=eks_node_group 25 | -i service_account_name=examples-user -i service_account_namespace=default 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/eks-feature-demo/resources/template.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: nginx 5 | spec: 6 | containers: 7 | - name: nginx 8 | image: nginx:stable 9 | -------------------------------------------------------------------------------- /examples/eks-feature-demo/scripts/store_kube_token_and_config.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import json 3 | 4 | from cloudify import ctx 5 | from cloudify.state import ctx_parameters as inputs 6 | from cloudify.manager import get_rest_client 7 | 8 | client = get_rest_client() 9 | token = base64.b64decode(inputs['kube_token']).decode('utf-8') 10 | client.secrets.create('kubernetes_token', token, update_if_exists=True) 11 | ctx.instance.runtime_properties['token'] = token 12 | kube_config = json.dumps(inputs['kube_config']) 13 | client.secrets.create('kubernetes_config', kube_config, update_if_exists=True) 14 | ctx.instance.runtime_properties['kube_config'] = kube_config 15 | -------------------------------------------------------------------------------- /examples/kms-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | iam_arn: 22 | type: string 23 | description: User arn 24 | 25 | dsl_definitions: 26 | 27 | client_config: &client_config 28 | aws_access_key_id: { get_input: aws_access_key_id } 29 | aws_secret_access_key: { get_input: aws_secret_access_key } 30 | aws_session_token: { get_secret: aws_session_token } 31 | region_name: { get_input: aws_region_name } 32 | 33 | node_templates: 34 | 35 | grant: 36 | type: cloudify.nodes.aws.kms.Grant 37 | properties: 38 | resource_config: 39 | kwargs: 40 | Name: TestGrant 41 | GranteePrincipal: { get_input: iam_arn } 42 | Operations: [Encrypt, Decrypt] 43 | client_config: *client_config 44 | relationships: 45 | - type: cloudify.relationships.depends_on 46 | target: cmk 47 | 48 | alias: 49 | type: cloudify.nodes.aws.kms.Alias 50 | properties: 51 | resource_config: 52 | kwargs: 53 | AliasName: alias/test_key 54 | client_config: *client_config 55 | relationships: 56 | - type: cloudify.relationships.depends_on 57 | target: cmk 58 | 59 | cmk: 60 | type: cloudify.nodes.aws.kms.CustomerMasterKey 61 | properties: 62 | resource_config: 63 | kwargs: 64 | Description: An example CMK. 65 | Tags: 66 | - TagKey: Cloudify 67 | TagValue: Example 68 | client_config: *client_config 69 | -------------------------------------------------------------------------------- /examples/lambda-feature-demo/function/main.py: -------------------------------------------------------------------------------- 1 | '''Example Lambda package file''' 2 | 3 | 4 | def lambda_handler(event, context): 5 | '''Example lambda function''' 6 | return 'Hello from Cloudify & Lambda' 7 | -------------------------------------------------------------------------------- /examples/lambda-feature-demo/function/main.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/examples/lambda-feature-demo/function/main.zip -------------------------------------------------------------------------------- /examples/natgateway-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: aws_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | aws_session_token: { get_secret: aws_session_token } 27 | region_name: { get_input: aws_region_name } 28 | 29 | node_templates: 30 | 31 | natgateway: 32 | type: cloudify.nodes.aws.ec2.NATGateway 33 | properties: 34 | client_config: *client_config 35 | resource_config: 36 | kwargs: 37 | ConnectivityType: private 38 | relationships: 39 | - type: cloudify.relationships.depends_on 40 | target: subnet 41 | - type: cloudify.relationships.depends_on 42 | target: elasticip 43 | 44 | elasticip: 45 | type: cloudify.nodes.aws.ec2.ElasticIP 46 | properties: 47 | resource_config: 48 | kwargs: 49 | Domain: 'vpc' 50 | client_config: *client_config 51 | 52 | subnet: 53 | type: cloudify.nodes.aws.ec2.Subnet 54 | properties: 55 | resource_config: 56 | CidrBlock: '172.30.0.0/24' 57 | kwargs: 58 | AvailabilityZone: { concat: [ { get_input: aws_region_name }, 'b' ] } 59 | client_config: *client_config 60 | Tags: 61 | - Key: Name 62 | Value: Subnet 63 | relationships: 64 | - type: cloudify.relationships.depends_on 65 | target: vpc 66 | 67 | vpc: 68 | type: cloudify.nodes.aws.ec2.Vpc 69 | properties: 70 | resource_config: 71 | CidrBlock: '172.30.0.0/16' 72 | kwargs: 73 | client_config: *client_config 74 | Tags: 75 | - Key: Name 76 | Value: VPC 77 | -------------------------------------------------------------------------------- /examples/s3-feature-demo/local-s3-object.txt: -------------------------------------------------------------------------------- 1 | S3 Test Uploaded File -------------------------------------------------------------------------------- /examples/s3-feature-demo/swift-blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | swift_username: 10 | type: string 11 | default: { get_input: swift_username } 12 | 13 | swift_password: 14 | type: string 15 | default: { get_input: swift_password } 16 | 17 | swift_auth_url: 18 | type: string 19 | default: { get_input: swift_auth_url } 20 | 21 | swift_region_name: 22 | type: string 23 | default: { get_input: swift_region_name } 24 | 25 | dsl_definitions: 26 | swift_config: &swift_config 27 | swift_username: { get_input: swift_username } 28 | swift_password: { get_input: swift_password } 29 | swift_auth_url: { get_input: swift_auth_url } 30 | swift_region_name: { get_input: swift_region_name } 31 | 32 | node_templates: 33 | 34 | bucket: 35 | type: cloudify.nodes.swift.s3.Bucket 36 | properties: 37 | resource_config: 38 | kwargs: 39 | ACL: 'public-read-write' 40 | Bucket: 'swift-test-bucket-2' 41 | CreateBucketConfiguration: 42 | LocationConstraint: { get_input: swift_region_name } 43 | swift_config: *swift_config 44 | 45 | bucket_object_bytes: 46 | type: cloudify.nodes.swift.s3.BucketObject 47 | properties: 48 | source_type: 'bytes' 49 | resource_config: 50 | kwargs: 51 | ACL: 'public-read' 52 | Body: 'Test Content' 53 | Bucket: { get_property: [ bucket, resource_config, kwargs, Bucket ] } 54 | Key: 'test-byte-data.txt' 55 | swift_config: *swift_config 56 | relationships: 57 | - type: cloudify.relationships.depends_on 58 | target: bucket 59 | 60 | bucket_object_local: 61 | type: cloudify.nodes.swift.s3.BucketObject 62 | properties: 63 | source_type: 'local' 64 | path: './local-s3-object.txt' 65 | resource_config: 66 | kwargs: 67 | ACL: 'public-read' 68 | Bucket: { get_property: [ bucket, resource_config, kwargs, Bucket ] } 69 | Key: 'local-s3-object.txt' 70 | swift_config: *swift_config 71 | relationships: 72 | - type: cloudify.relationships.depends_on 73 | target: bucket 74 | 75 | bucket_object_remote: 76 | type: cloudify.nodes.swift.s3.BucketObject 77 | properties: 78 | source_type: 'remote' 79 | path: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf' 80 | resource_config: 81 | kwargs: 82 | ACL: 'public-read' 83 | Bucket: { get_property: [ bucket, resource_config, kwargs, Bucket ] } 84 | Key: 'dummy.pdf' 85 | swift_config: *swift_config 86 | relationships: 87 | - type: cloudify.relationships.depends_on 88 | target: bucket 89 | -------------------------------------------------------------------------------- /examples/security-group-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | vpc: 22 | type: string 23 | 24 | dsl_definitions: 25 | 26 | client_config: &client_config 27 | aws_access_key_id: { get_input: aws_access_key_id } 28 | aws_secret_access_key: { get_input: aws_secret_access_key } 29 | region_name: { get_input: aws_region_name } 30 | 31 | node_templates: 32 | 33 | security_group0: 34 | type: cloudify.nodes.aws.ec2.SecurityGroup 35 | properties: 36 | resource_config: 37 | Description: Example. 38 | GroupName: security_group0 39 | kwargs: 40 | VpcId: { get_input: vpc } 41 | client_config: *client_config 42 | 43 | security_group1: 44 | type: cloudify.nodes.aws.ec2.SecurityGroup 45 | properties: 46 | resource_config: 47 | Description: Example. 48 | GroupName: security_group1 49 | kwargs: 50 | VpcId: { get_input: vpc } 51 | client_config: *client_config 52 | 53 | security_group_rules: 54 | type: cloudify.nodes.aws.ec2.SecurityGroupRuleIngress 55 | properties: 56 | client_config: *client_config 57 | resource_config: 58 | kwargs: 59 | IpPermissions: 60 | - IpProtocol: icmp 61 | FromPort: -1 62 | ToPort: -1 63 | IpRanges: 64 | - CidrIp: 0.0.0.0/0 65 | UserIdGroupPairs: [ { GroupId: { get_attribute: [ security_group1, aws_resource_id ] } } ] 66 | relationships: 67 | - type: cloudify.relationships.contained_in 68 | target: security_group0 69 | - type: cloudify.relationships.depends_on 70 | target: security_group1 71 | -------------------------------------------------------------------------------- /examples/sns-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id2 } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key2 } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | region_name: { get_input: aws_region_name } 27 | 28 | node_templates: 29 | 30 | subscription: 31 | type: cloudify.nodes.aws.SNS.Subscription 32 | properties: 33 | client_config: *client_config 34 | resource_config: 35 | kwargs: 36 | Protocol: sqs 37 | Endpoint: queue # Should match the target of a relationship if it is not arn 38 | relationships: 39 | - type: cloudify.relationships.depends_on 40 | target: topic 41 | - type: cloudify.relationships.depends_on 42 | target: queue 43 | 44 | topic: 45 | type: cloudify.nodes.aws.SNS.Topic 46 | properties: 47 | resource_config: 48 | kwargs: 49 | Name: TestCloudifyTopic 50 | client_config: *client_config 51 | 52 | queue: 53 | type: cloudify.nodes.aws.SQS.Queue 54 | properties: 55 | resource_config: 56 | kwargs: 57 | QueueName: test-queue 58 | Attributes: 59 | Policy: | 60 | { 61 | "Version": "2012-10-17", 62 | "Statement": [ 63 | { 64 | "Sid": "Sid1", 65 | "Effect": "Allow", 66 | "Principal": "*", 67 | "Action": [ 68 | "SQS:SendMessage", 69 | "SQS:ReceiveMessage" 70 | ], 71 | "Resource": "test-queue" 72 | } 73 | ] 74 | } 75 | MessageRetentionPeriod: '86400' 76 | VisibilityTimeout: '180' 77 | client_config: *client_config 78 | -------------------------------------------------------------------------------- /examples/sqs-feature-demo/blueprint.yaml: -------------------------------------------------------------------------------- 1 | tosca_definitions_version: cloudify_dsl_1_5 2 | 3 | imports: 4 | - cloudify/types/types.yaml 5 | - plugin:cloudify-aws-plugin 6 | 7 | inputs: 8 | 9 | aws_access_key_id: 10 | type: string 11 | default: { get_secret: aws_access_key_id } 12 | 13 | aws_secret_access_key: 14 | type: string 15 | default: { get_secret: aws_secret_access_key } 16 | 17 | aws_region_name: 18 | type: string 19 | default: { get_secret: ec2_region_name } 20 | 21 | dsl_definitions: 22 | 23 | client_config: &client_config 24 | aws_access_key_id: { get_input: aws_access_key_id } 25 | aws_secret_access_key: { get_input: aws_secret_access_key } 26 | aws_session_token: { get_secret: aws_session_token } 27 | region_name: { get_input: aws_region_name } 28 | 29 | node_templates: 30 | 31 | queue: 32 | type: cloudify.nodes.aws.SQS.Queue 33 | properties: 34 | resource_config: 35 | kwargs: 36 | # QueueName: test-queue 37 | Attributes: 38 | Policy: 39 | { 40 | "Version": "2012-10-17", 41 | "Statement": [ 42 | { 43 | "Sid": "Sid1", 44 | "Effect": "Deny", 45 | "Principal": "*", 46 | "Action": [ 47 | "SQS:SendMessage", 48 | "SQS:ReceiveMessage" 49 | ], 50 | "Resource": "test-queue", 51 | "Condition": { 52 | "DateGreaterThan" : { 53 | "aws:CurrentTime" : "2013-12-15T12:00:00Z" 54 | } 55 | } 56 | } 57 | ] 58 | } 59 | MessageRetentionPeriod: '86400' 60 | VisibilityTimeout: '180' 61 | client_config: *client_config 62 | -------------------------------------------------------------------------------- /extra-packaging-instructions.sh: -------------------------------------------------------------------------------- 1 | if [[ $PY311 == 1 ]] 2 | then 3 | mkdir -p ./pydoc 4 | touch ./pydoc/__init__.py 5 | cat < ./pydoc/__init__.py 6 | def get_doc(*args): 7 | return '' 8 | EOF 9 | mkdir -p ./webbrowser 10 | touch ./webbrowser/__init__.py 11 | cat < ./webbrowser/__init__.py 12 | EOF 13 | fi 14 | -------------------------------------------------------------------------------- /ignore_plugin_yaml_differences: -------------------------------------------------------------------------------- 1 | {'dictionary_item_added': [root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['Policies']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['LambdaConfig']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['AutoVerifiedAttributes']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['AliasAttributes']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['UsernameAttributes']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['VerificationMessageTemplate']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['UserAttributeUpdateSettings']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['DeviceConfiguration']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['EmailConfiguration']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['SmsConfiguration']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['UserPoolTags']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['AdminCreateUserConfig']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['Schema']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['UserPoolAddOns']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['UsernameConfiguration']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPool.config']['properties']['AccountRecoverySetting']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['TokenValidityUnits']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['ReadAttributes']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['CallbackURLs']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['ExplicitAuthFlows']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['SupportedIdentityProviders']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['LogoutURLs']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['AllowedOAuthFlows']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['AllowedOAuthScopes']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.UserPoolClient.config']['properties']['AnalyticsConfiguration']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.IdentityProvider.config']['properties']['ProviderDetails']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.IdentityProvider.config']['properties']['AttributeMapping']['type'], root['data_types']['cloudify.datatypes.aws.cognitoidp.IdentityProvider.config']['properties']['IdpIdentifiers']['type'], root['data_types']['cloudify.datatypes.aws.cognito.IdentityPool.config']['properties']['SupportedLoginProviders']['type'], root['data_types']['cloudify.datatypes.aws.cognito.IdentityPool.config']['properties']['OpenIdConnectProviderARNs']['type'], root['data_types']['cloudify.datatypes.aws.cognito.IdentityPool.config']['properties']['CognitoIdentityProviders']['type'], root['data_types']['cloudify.datatypes.aws.cognito.IdentityPool.config']['properties']['SamlProviderARNs']['type'], root['data_types']['cloudify.datatypes.aws.cognito.IdentityPool.config']['properties']['IdentityPoolTags']['type']]} 2 | -------------------------------------------------------------------------------- /pydoc/__init__.py: -------------------------------------------------------------------------------- 1 | def get_doc(*args): 2 | return '' 3 | -------------------------------------------------------------------------------- /requirements-3.6.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/requirements-3.6.in -------------------------------------------------------------------------------- /requirements.in: -------------------------------------------------------------------------------- 1 | -e fusion-common 2 | -e fusion-manager/mgmtworker 3 | -e fusion-agent 4 | -e cloudify-utilities-plugins-sdk 5 | cryptography>=41.0.5 6 | cffi==1.14.6 7 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Cloudify Platform LTD. All rights reserved 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | import re 17 | import sys 18 | import pathlib 19 | 20 | from setuptools import setup 21 | from setuptools import find_packages 22 | 23 | 24 | def get_version(): 25 | current_dir = pathlib.Path(__file__).parent.resolve() 26 | with open(os.path.join(current_dir, 'cloudify_aws/__version__.py'), 27 | 'r') as outfile: 28 | var = outfile.read() 29 | return re.search(r'\d+.\d+.\d+', var).group() 30 | 31 | install_requires=[ 32 | 'boto3', 33 | 'botocore', 34 | 'datetime', 35 | 'pycryptodome>=3.20.0', 36 | 'cloudify-utilities-plugins-sdk>=0.0.128', 37 | ] 38 | 39 | if sys.version_info.major == 3 and sys.version_info.minor == 6: 40 | packages = ['cloudify_aws'] 41 | install_requires += [ 42 | 'deepdiff==3.3.0', 43 | 'cloudify-common>=4.5,<7.0.0', 44 | ] 45 | else: 46 | packages = find_packages(exclude=['tests*']) 47 | install_requires += [ 48 | 'deepdiff==5.7.0', 49 | 'fusion-common', 50 | ] 51 | 52 | setup( 53 | name='cloudify-aws-plugin', 54 | version=get_version(), 55 | author='Cloudify Platform Ltd.', 56 | author_email='hello@cloudify.co', 57 | license='LICENSE', 58 | packages=packages, 59 | description='A Cloudify plugin for AWS', 60 | install_requires=install_requires 61 | ) 62 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | mock 2 | nose 3 | flake8 4 | pylint 5 | coverage 6 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = unittesting,linting 3 | minversion = 1.6 4 | skipsdist = True 5 | 6 | [testenv] 7 | setenv = 8 | VIRTUAL_ENV={envdir} 9 | 10 | # NOTE: relative paths were used due to '-w' flag for nosetests util 11 | 12 | usedevelop = True 13 | install_command = pip install -U {opts} {packages} 14 | deps = 15 | -e {toxinidir}/ 16 | -r{toxinidir}/requirements-3.6.txt 17 | -r{toxinidir}/test-requirements.txt 18 | whitelist_externals = bash 19 | 20 | [testenv:linting] 21 | commands = 22 | flake8 --ignore=W605 cloudify_aws --exclude cloudify_aws/cognito/scripts/* 23 | 24 | [testenv:unittesting] 25 | commands = 26 | nosetests --cover-html --with-coverage --cover-package=cloudify_aws --with-xunit --xunit-file=nosetests.xml --cover-xml --cover-xml-file=coverage.xml --exe cloudify_aws 27 | -------------------------------------------------------------------------------- /webbrowser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-aws-plugin/e00b5944d83d2135bfa3a69ee4c343f913035252/webbrowser/__init__.py --------------------------------------------------------------------------------