From 1032694f518ea3d42e246a7ab11b22442eb1cd54 Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Thu, 14 Jul 2022 15:33:38 +0000 Subject: [PATCH 1/4] add ssm to CFT --- cloudformation/dle_cf_template.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cloudformation/dle_cf_template.yaml b/cloudformation/dle_cf_template.yaml index 02e942380..4834a59a4 100644 --- a/cloudformation/dle_cf_template.yaml +++ b/cloudformation/dle_cf_template.yaml @@ -288,6 +288,28 @@ Conditions: !Not [Condition: CreateSubDomain] Resources: + IamSSMRole: + Type: "AWS::IAM::Role" + Properties: + RoleName: "EC2RoleForSSM" + Description: "EC2 IAM role for SSM access" + AssumeRolePolicyDocument: + Version: "2012-10-17" + Statement: + - Effect: "Allow" + Principal: + Service: + - "ec2.amazonaws.com" + Action: + - "sts:AssumeRole" + ManagedPolicyArns: + - "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore" + EC2SSMInstanceProfile: + Type: "AWS::IAM::InstanceProfile" + Properties: + InstanceProfileName: "EC2RoleForSSM" + Roles: + - Ref: "IamSSMRole" LambdaExecutionRole: Type: AWS::IAM::Role Properties: @@ -344,6 +366,7 @@ Resources: - !Ref InstanceType - Arch InstanceType: !Ref InstanceType + IamInstanceProfile: !Ref EC2SSMInstanceProfile SecurityGroupIds: !If - CreateSubDomain - - !GetAtt DLESecurityGroup.GroupId -- GitLab From 246c691d043b59accf20b35319b67c351b9be6ea Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Thu, 14 Jul 2022 16:40:11 +0000 Subject: [PATCH 2/4] added DLE cli init --- cloudformation/dle_cf_template.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cloudformation/dle_cf_template.yaml b/cloudformation/dle_cf_template.yaml index 4834a59a4..cccc46619 100644 --- a/cloudformation/dle_cf_template.yaml +++ b/cloudformation/dle_cf_template.yaml @@ -478,6 +478,15 @@ Resources: while ! echo "UI started" | nc localhost 2346; do sleep 10; done /opt/aws/bin/cfn-signal -e $? -d "DLE UI is available" -r "DLE Deploy Process Complete" '${WaitHandle}' + # Initialize CLI configuration + sudo su - ubuntu + /usr/local/bin/dblab init \ + --environment-id=test \ + --url=http://localhost:2345 \ + --token=${DLEVerificationToken} \ + --insecure + + WaitHandle: Type: AWS::CloudFormation::WaitConditionHandle WaitCondition: -- GitLab From b5529404488a9a7349fc8e7e0254abc1848e5bad Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Thu, 14 Jul 2022 17:49:52 +0000 Subject: [PATCH 3/4] added DLE cli init --- cloudformation/dle_cf_template.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cloudformation/dle_cf_template.yaml b/cloudformation/dle_cf_template.yaml index cccc46619..4d5f769ad 100644 --- a/cloudformation/dle_cf_template.yaml +++ b/cloudformation/dle_cf_template.yaml @@ -479,13 +479,11 @@ Resources: /opt/aws/bin/cfn-signal -e $? -d "DLE UI is available" -r "DLE Deploy Process Complete" '${WaitHandle}' # Initialize CLI configuration - sudo su - ubuntu - /usr/local/bin/dblab init \ + su ubuntu -c '/usr/local/bin/dblab init \ --environment-id=test \ --url=http://localhost:2345 \ --token=${DLEVerificationToken} \ - --insecure - + --insecure' WaitHandle: Type: AWS::CloudFormation::WaitConditionHandle -- GitLab From ff39c8bcda5e4c8e9257d587d70519ae638fae8c Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Thu, 14 Jul 2022 18:26:19 +0000 Subject: [PATCH 4/4] added DLE cli init --- cloudformation/dle_cf_template.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cloudformation/dle_cf_template.yaml b/cloudformation/dle_cf_template.yaml index 4d5f769ad..b5acd3e36 100644 --- a/cloudformation/dle_cf_template.yaml +++ b/cloudformation/dle_cf_template.yaml @@ -474,9 +474,11 @@ Resources: sudo systemctl enable envoy sudo systemctl start envoy fi - - while ! echo "UI started" | nc localhost 2346; do sleep 10; done - /opt/aws/bin/cfn-signal -e $? -d "DLE UI is available" -r "DLE Deploy Process Complete" '${WaitHandle}' + + # upgrade ssm agent version + wget https://s3.us-east-1.amazonaws.com/amazon-ssm-us-east-1/amazon-ssm-agent/3.1.1575.0/amazon-ssm-agent-ubuntu-amd64.tar.gz + tar -xf amazon-ssm-agent-ubuntu-amd64.tar.gz + bash snap-install.sh # Initialize CLI configuration su ubuntu -c '/usr/local/bin/dblab init \ @@ -484,6 +486,9 @@ Resources: --url=http://localhost:2345 \ --token=${DLEVerificationToken} \ --insecure' + + while ! echo "UI started" | nc localhost 2346; do sleep 10; done + /opt/aws/bin/cfn-signal -e $? -d "DLE UI is available" -r "DLE Deploy Process Complete" '${WaitHandle}' WaitHandle: Type: AWS::CloudFormation::WaitConditionHandle -- GitLab