Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

Expand Down Expand Up @@ -37,3 +34,5 @@ node_modules

# File generated by the inventory-collector should not be committed
inventory.csv

.venv
8 changes: 4 additions & 4 deletions elastio-deployment/cloudformation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Here are some links to the released versions of both Cloudformation templates.

### `connector.yaml` template

- [Single-click deployment link](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v1/connector.yaml&stackName=elastio-connector)
- [Template download link](https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v1/connector.yaml)
- [Single-click deployment link](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v2/connector.yaml&stackName=elastio-connector)
- [Template download link](https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v2/connector.yaml)

### `connector-region.yaml` template

- [Single-click deployment link](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v1/connector-region.yaml&stackName=elastio-connector-region)
- [Template download link](https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v1/connector-region.yaml)
- [Single-click deployment link](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v2/connector-region.yaml&stackName=elastio-connector-region)
- [Template download link](https://elastio-prod-artifacts-us-east-1.s3.us-east-1.amazonaws.com/contrib/elastio-deployment/cloudformation/v2/connector-region.yaml)
26 changes: 18 additions & 8 deletions elastio-deployment/cloudformation/connector-region.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Parameters:
If not set or empty,then Elastio will create an Elastio-managed VPC for the connector.
Make sure to enable 'Auto-Create VPC' option for the Connector Account stack.

ElastioConnectorAccountStackVersion:
Type: String
Default: ''
Description: >
The version of the deployed Elastio Connector Account stack. This
parameter is used only to ensure that the connector region stack
deployment is re-triggred when the Connector Account stack is updated.

Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
Expand Down Expand Up @@ -97,14 +105,6 @@ Resources:
MemorySize: 512
Timeout: 600
Role: !GetAtt LambdaRole.Arn

Environment:
Variables:
ELASTIO_PAT: !Ref ElastioPat
ELASTIO_TENANT: !Ref ElastioTenant
ELASTIO_AWS_ACCOUNT_ID: !Ref AWS::AccountId
ELASTIO_VPC_ID: !Ref ElastioVpcId
ELASTIO_SUBNET_IDS: !Join [',', !Ref ElastioSubnetIds]
Code:
S3Bucket: !Sub '{{S3_BUCKET_PREFIX}}-${AWS::Region}'
S3Key: {{S3_KEY_PREFIX}}/{{VERSION}}/lambda.zip
Expand All @@ -116,6 +116,16 @@ Resources:
DeletionPolicy: Delete
Properties:
ServiceToken: !GetAtt LambdaFunction.Arn
ServiceTimeout: 60
ElastioPat: !Ref ElastioPat
ElastioTenant: !Ref ElastioTenant
ElastioAwsAccountId: !Ref AWS::AccountId
ElastioVpcId: !Ref ElastioVpcId
ElastioSubnetIds: !Join [',', !Ref ElastioSubnetIds]

# Make sure an update is triggered when versions change
ElastioConnectorAccountStackVersion: !Ref ElastioConnectorAccountStackVersion
ElastioConnectorRegionDelegatorStackVersion: '{{VERSION}}'

Outputs:
templateVersion:
Expand Down
3 changes: 3 additions & 0 deletions elastio-deployment/cloudformation/connector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ Resources:
Tags:
- Key: elastio:resource
Value: 'true'
- Key: elastio:connector:account:stack-version
Value: !GetAtt account.Outputs.accountStackVersion
Parameters:
ElastioTenant: !Ref ElastioTenant
ElastioPat: !Ref ElastioPat
ElastioVpcId: !Ref ElastioVpcId
ElastioSubnetIds: !Join [',', !Ref ElastioSubnetIds]
ElastioConnectorAccountStackVersion: !GetAtt account.Outputs.accountStackVersion
16 changes: 9 additions & 7 deletions elastio-deployment/cloudformation/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ def send_cfn_response(status, reason=None):
print(response.read().decode())

try:
print(f"Received event: {json.dumps(event)}")

if event["RequestType"] == "Create" or event["RequestType"] == "Update":
run()
run(event["ResourceProperties"])
send_cfn_response("SUCCESS")
except HTTPError as e:
send_cfn_response("FAILED", f"{e}: {e.read().decode()}")
Expand All @@ -38,19 +40,19 @@ def send_cfn_response(status, reason=None):
raise


def run():
elastio_pat = os.environ["ELASTIO_PAT"]
elastio_tenant = os.environ["ELASTIO_TENANT"]
def run(props):
elastio_pat = props["ElastioPat"]
elastio_tenant = props["ElastioTenant"]
elastio_endpoint = f"https://{elastio_tenant}/public-api/v1"

subnet_ids = os.environ.get("ELASTIO_SUBNET_IDS")
subnet_ids = props.get("ElastioSubnetIds")

request_body = {
"region": os.environ["AWS_REGION"],
"account_id": os.environ["ELASTIO_AWS_ACCOUNT_ID"],
"account_id": props["ElastioAwsAccountId"],
#
# None `vpc_id/subnet_ids` means we'll create a new Elastio-managed VPC
"vpc_id": os.environ.get("ELASTIO_VPC_ID") or None,
"vpc_id": props.get("ElastioVpcId") or None,
"subnet_ids": subnet_ids.split(",") if subnet_ids else None,
}

Expand Down
2 changes: 1 addition & 1 deletion elastio-deployment/cloudformation/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1
v2