Skip to content

Commit

Permalink
Merge pull request #482 from cloudify-cosmo/3.1.0-build
Browse files Browse the repository at this point in the history
3.1.0 build
  • Loading branch information
EarthmanT authored Oct 31, 2022
2 parents 96e9f16 + 4fdc221 commit 843d8d2
Show file tree
Hide file tree
Showing 59 changed files with 7,478 additions and 96 deletions.
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: 2.1

orbs:
node: cloudify/public-unittest-orb@1 #orb version
wagonorb: cloudify/wagon-bulder-orb@2.4.0 #orb version
releaseorb: cloudify/release-orb@1.4.0 #orb version
managerorb: cloudify/manager-orb@2.0.1
wagonorb: cloudify/wagon-bulder-orb@2 #orb version
releaseorb: cloudify/release-orb@1 #orb version
managerorb: cloudify/manager-orb@2

checkout:
post:
Expand All @@ -29,7 +29,13 @@ commands:
prepare_test_manager:
steps:
- run: ls -alR
- run: ecosystem-test prepare-test-manager -l $TEST_LICENSE -es aws_access_key_id=$aws_access_key_id -es aws_secret_access_key=$aws_secret_access_key --bundle-path workspace/build/cloudify-plugins-bundle.tgz --yum-package python-netaddr --yum-package git
- run: ecosystem-test prepare-test-manager -l $TEST_LICENSE -es aws_access_key_id=$aws_access_key_id -es aws_secret_access_key=$aws_secret_access_key --yum-package python-netaddr --yum-package git
- run: ecosystem-test upload-plugin -PN utilities
- run: ecosystem-test upload-plugin -PN ansible
- run: ecosystem-test upload-plugin -PN kubernetes
- run: |
docker exec -it cfy_manager mkdir -p /etc/cloudify/.cloudify/profiles/manager-local/
docker exec -it cfy_manager cp /root/.cloudify/profiles/manager-local/context.json /etc/cloudify/.cloudify/profiles/manager-local/context.json
run_hello_world_test:
steps:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,3 @@ local-storage/
plugin_docs
workspace
*.wgn
resources
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
3.1.0:
- RD 5833 DSL 1.5 Plugin YAML.
- Handle malformed xml in s3 empty CreateBucketConfiguration.
- updated cleanup_vpc_internet_gateways, so detaching of igw has vpc id as well.
- ec2 resources will check that deletion will be successful using dry run before deleting tags
- image resources check node properties instead of runtime properties
- Add cognito.
3.0.10: Workflow availability.
3.0.9: Add Status reports in CF.
3.0.8:
Expand Down
64 changes: 64 additions & 0 deletions cloudify_aws/cognito/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Cognito
~~~~~~~
AWS Cognito base interface
"""
# Cloudify AWS
from cloudify_aws.common import AWSResourceBase
from cloudify_aws.common.connection import Boto3Connection

# pylint: disable=R0903


class CognitoBase(AWSResourceBase):
"""
AWS Cognito base interface
"""
def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
AWSResourceBase.__init__(
self, client or Boto3Connection(ctx_node).client('cognito-idp'),
resource_id=resource_id, logger=logger)
self.ctx_node = ctx_node

@property
def properties(self):
"""Gets the properties of an external resource"""
raise NotImplementedError()

@property
def status(self):
"""Gets the status of an external resource"""
raise NotImplementedError()

def create(self, params):
"""Creates a resource"""
raise NotImplementedError()

def delete(self, params=None):
"""Deletes a resource"""
raise NotImplementedError()


class CognitoIdentityBase(AWSResourceBase):
"""
AWS Cognito base interface
"""
def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
AWSResourceBase.__init__(
self,
client or Boto3Connection(ctx_node).client('cognito-identity'),
resource_id=resource_id, logger=logger)
self.ctx_node = ctx_node
Empty file.
143 changes: 143 additions & 0 deletions cloudify_aws/cognito/resources/identity_pool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Cognito.identity_pool
~~~~~~~~
AWS Cognito Identity Pool interface
"""

# Third party imports
from botocore.exceptions import ClientError, ParamValidationError

# Local imports
from ...iam.resources.role import IAMRole
from cloudify_aws.common import decorators, utils
from cloudify_aws.cognito import CognitoIdentityBase

RESOURCE_NAME = 'IdentityPoolName'
DESCRIBE_INDEX = 'IdentityPoolId'
RESOURCE_TYPE = 'Cognito Identity Pool'


class CognitoIdentityPool(CognitoIdentityBase):
"""
AWS Cognito Identity Pool
"""
def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
CognitoIdentityBase.__init__(
self, ctx_node, resource_id, client, logger)
self.type_name = RESOURCE_TYPE

@property
def properties(self):
"""Gets the properties of an external resource"""
if self.resource_id:
try:
resource = self.client.describe_identity_pool(
IdentityPoolId=self.resource_id)
except (ParamValidationError, ClientError):
pass
else:
return resource.get(DESCRIBE_INDEX, {})
return {}

@property
def status(self):
"""Gets the status of an external resource"""
return self.properties

def create(self, params):
"""Create a new AWS Cognito Identity Pool."""
return self.make_client_call('create_identity_pool', params)

def delete(self, params=None):
"""Delete a new AWS Cognito Identity Pool."""
return self.make_client_call('delete_identity_pool', params)

def get_roles(self):
return self.client.get_identity_pool_roles(
IdentityPoolId=self.resource_id)

def set_roles(self, params):
return self.make_client_call('set_identity_pool_roles', params)


@decorators.aws_resource(CognitoIdentityPool, RESOURCE_TYPE)
def prepare(ctx, resource_config, **_):
"""Prepares an AWS Cognito Identity Pool"""
# Save the parameters
ctx.instance.runtime_properties['resource_config'] = resource_config


@decorators.aws_resource(CognitoIdentityPool, RESOURCE_TYPE)
def create(ctx, iface, resource_config, **_):
"""Creates an AWS Cognito Identity Pool"""
create_response = iface.create(resource_config)
utils.update_resource_id(
ctx.instance, create_response['IdentityPoolId'])


@decorators.aws_resource(CognitoIdentityPool,
RESOURCE_TYPE,
ignore_properties=True)
def delete(iface, resource_config, **_):
"""Deletes an AWS Cognito Identity Pool"""
iface.delete(
{
'IdentityPoolId': utils.get_resource_id()
}
)


@decorators.aws_relationship(IAMRole, RESOURCE_TYPE)
def set(ctx, iface, **_):
"""Deletes an AWS Cognito Identity Pool"""
identity_pool = CognitoIdentityPool(
ctx.target.node,
ctx.target.instance.runtime_properties['aws_resource_id'],
logger=ctx.logger,
)
roles = identity_pool.get_roles()
if ctx.source.node.id not in roles.get('Roles', {}):
updated_roles = roles.get('Roles', {})
updated_roles.update({
ctx.source.node.id: utils.get_resource_arn(
ctx.source.node,
ctx.source.instance,
raise_on_missing=True
)
})
identity_pool.set_roles({
'IdentityPoolId': identity_pool.resource_id,
'Roles': updated_roles,
})


@decorators.aws_relationship(IAMRole, RESOURCE_TYPE)
def unset(ctx, iface, **_):
"""Deletes an AWS Cognito Identity Pool"""
identity_pool = CognitoIdentityPool(
ctx.target.node,
ctx.target.instance.runtime_properties['aws_resource_id'],
logger=ctx.logger,
)
roles = identity_pool.get_roles()
if ctx.source.node.id in roles.get('Roles', {}):
updated_roles = roles.get('Roles', {})
del updated_roles[ctx.source.node.id]
identity_pool.set_roles({
'IdentityPoolId': identity_pool.resource_id,
'Roles': updated_roles,
})
119 changes: 119 additions & 0 deletions cloudify_aws/cognito/resources/identity_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Cognito.identity_provider
~~~~~~~~
AWS Cognito Identity Provider interface
"""

# Third party imports
from botocore.exceptions import ClientError, ParamValidationError

# Local imports
from cloudify_aws.common import decorators, utils
from cloudify_aws.cognito import CognitoBase

RESOURCE_NAME = 'ProviderName'
DESCRIBE_INDEX = 'IdentityProvider'
RESOURCE_TYPE = 'Cognito Identity Provider'


class CognitoIdentityProvider(CognitoBase):
"""
AWS Cognito Identity interface
"""
def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
CognitoBase.__init__(self, ctx_node, resource_id, client, logger)
self.type_name = RESOURCE_TYPE
self._provider_name = \
self.ctx_node.properties['resource_config']['ProviderName']
self._user_pool_id = \
self.ctx_node.properties['resource_config']['UserPoolId']

@property
def provider_name(self):
return self._provider_name

@provider_name.setter
def provider_name(self, value):
self._provider_name = value

@property
def user_pool_id(self):
return self._user_pool_id

@user_pool_id.setter
def user_pool_id(self, value):
self._user_pool_id = value

@property
def properties(self):
"""Gets the properties of an external resource"""
if self.resource_id:
try:
resource = self.client.describe_identity_provider(
UserPoolId=self.user_pool_id,
ProviderName=self.resource_id)
except (ParamValidationError, ClientError):
pass
else:
return resource.get(DESCRIBE_INDEX, {})
return {}

@property
def status(self):
"""Gets the status of an external resource"""
return self.properties.get('Status')

def create(self, params):
"""Create a new AWS Cognito Identity Provider."""
return self.make_client_call('create_identity_provider', params)

def delete(self, params=None):
"""Delete a new AWS Cognito Identity Provider."""
return self.make_client_call('delete_identity_provider', params)


@decorators.aws_resource(CognitoIdentityProvider, RESOURCE_TYPE)
def prepare(ctx, resource_config, **_):
"""Prepares an AWS Cognito Identity Provider"""
# Save the parameters
ctx.instance.runtime_properties['resource_config'] = resource_config


@decorators.aws_resource(CognitoIdentityProvider, RESOURCE_TYPE)
def create(ctx, iface, resource_config, **_):
"""Creates an AWS Cognito Identity Provider"""
create_response = iface.create(resource_config)
utils.update_resource_id(
ctx.instance, create_response['IdentityProvider']['ProviderName'])
ctx.instance.runtime_properties['create_response'] = \
utils.JsonCleanuper(create_response).to_dict()


@decorators.aws_resource(CognitoIdentityProvider,
RESOURCE_TYPE)
def delete(iface, resource_config, **_):
"""Deletes an AWS Cognito Identity Provider"""
iface.user_pool_id = resource_config.get(
'UserPoolId') or iface.user_pool_id
iface.provider_name = resource_config.get(
'ProviderName') or iface.provider_name
iface.delete(
{
'UserPoolId': iface.user_pool_id,
'ProviderName': iface.provider_name,
}
)
Loading

0 comments on commit 843d8d2

Please sign in to comment.