Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into spotnodes
Browse files Browse the repository at this point in the history
  • Loading branch information
svennam92 committed Oct 11, 2023
2 parents 5610ce5 + 80710d4 commit 3c92958
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 78 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ env

cdk.out

.envrc
.envrc
node_modules
65 changes: 25 additions & 40 deletions lab/cfn/eks-workshop-ide-cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Parameters:
Type: String
Description: Name of the Cloud9 instance
Default: "none"
Cloud9Subnet:
Type: String
Description: If you want Cloud9 in a specific subnet
Default: "none"
ResourcesPrecreated:
Type: String
Description: Whether lab infrastructure has been pre-provisioned
Expand All @@ -55,6 +59,7 @@ Parameters:
Conditions:
Create3rdPartyResources: !Equals [ !Ref EksWorkshopC9EnvType, 3rdParty ]
IsCloud9NotNamed: !Equals [ !Ref Cloud9Name, none ]
IsCloud9SubnetSpecified: !Not [ !Equals [ !Ref Cloud9Subnet, none ]]

Resources:
EksWorkshopC9Role:
Expand Down Expand Up @@ -124,12 +129,8 @@ Resources:
Resource: "*"

EksWorkshopC9BootstrapInstanceLambda:
Description: Bootstrap Cloud9 instance
Type: Custom::EksWorkshopC9BootstrapInstanceLambda
DependsOn:
- EksWorkshopC9BootstrapInstanceLambdaFunction
- EksWorkshopC9Instance
- EksWorkshopC9InstanceProfile
- EksWorkshopC9LambdaExecutionRole
Properties:
ServiceToken:
Expand Down Expand Up @@ -159,6 +160,10 @@ Resources:
- EksWorkshopC9LambdaExecutionRole
- Arn
Runtime: python3.9
Environment:
Variables:
DiskSize:
Ref: EksWorkshopC9InstanceVolumeSize
MemorySize: 256
Timeout: '600'
Code:
Expand All @@ -170,10 +175,12 @@ Resources:
import time
import traceback
import cfnresponse
import logging
logger = logging.getLogger(__name__)
def lambda_handler(event, context):
print(event.values())
# logger.info('context: {}'.format(context))
logger.info('context: {}'.format(context))
responseData = {}
status = cfnresponse.SUCCESS
Expand All @@ -189,25 +196,25 @@ Resources:
# Get the InstanceId of the Cloud9 IDE
instance = ec2.describe_instances(Filters=[{'Name': 'tag:Name','Values': ['aws-cloud9-'+event['ResourceProperties']['Cloud9Name']+'-'+event['ResourceProperties']['EnvironmentId']]}])['Reservations'][0]['Instances'][0]
# logger.info('instance: {}'.format(instance))
logger.info('instance: {}'.format(instance))
instance_id = instance['InstanceId']
# Create the IamInstanceProfile request object
iam_instance_profile = {
'Arn': event['ResourceProperties']['LabIdeInstanceProfileArn'],
'Name': event['ResourceProperties']['LabIdeInstanceProfileName']
}
# logger.info('iam_instance_profile: {}'.format(iam_instance_profile))
logger.info('iam_instance_profile: {}'.format(iam_instance_profile))
time.sleep(10)
# Wait for Instance to become ready before adding Role
instance_state = instance['State']['Name']
# logger.info('instance_state: {}'.format(instance_state))
logger.info('instance_state: {}'.format(instance_state))
while instance_state != 'running':
time.sleep(5)
instance_state = ec2.describe_instances(InstanceIds=[instance_id])
# logger.info('instance_state: {}'.format(instance_state))
logger.info('instance_state: {}'.format(instance_state))
associations = ec2.describe_iam_instance_profile_associations(
Filters=[
Expand All @@ -230,8 +237,11 @@ Resources:
block_device = ec2.describe_volumes(VolumeIds=[block_volume_id])['Volumes'][0]
if block_device['Size'] != 30:
ec2.modify_volume(VolumeId=block_volume_id,Size=30)
DiskSize = int(os.environ['DiskSize'])
if block_device['Size'] < DiskSize:
ec2.modify_volume(VolumeId=block_volume_id,Size=DiskSize)
logger.info('Modifying block volume: {}'.format(block_volume_id))
time.sleep(10)
for i in range(1, 30):
response = ssm.describe_instance_information(Filters=[{'Key': 'InstanceIds', 'Values': [instance_id]}])
Expand Down Expand Up @@ -286,34 +296,6 @@ Resources:
- !Sub |
set -e
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""

marker_file="/root/resized.mark"

if [[ ! -f "$marker_file" ]]; then
if [ $(readlink -f /dev/xvda) = "/dev/xvda" ]
then
sudo growpart /dev/xvda 1
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/xvda1
fi
else
sudo growpart /dev/nvme0n1 1
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/nvme0n1p1
fi
fi
fi

touch $marker_file

export AWS_REGION="${AWS::Region}"
export REPOSITORY_OWNER="${RepositoryOwner}"
export REPOSITORY_NAME="${RepositoryName}"
Expand All @@ -325,6 +307,9 @@ Resources:

sudo -E -H -u ec2-user bash -c "curl -fsSL https://raw.githubusercontent.com/${RepositoryOwner}/${RepositoryName}/${RepositoryRef}/lab/scripts/setup.sh | bash"

echo 'Rebooting...'
reboot

EksWorkshopC9InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Expand All @@ -333,14 +318,14 @@ Resources:
- Ref: EksWorkshopC9Role

EksWorkshopC9Instance:
Description: "-"
Type: AWS::Cloud9::EnvironmentEC2
Properties:
Description: AWS Cloud9 instance for EKS Workshop
ImageId: amazonlinux-2-x86_64
AutomaticStopTimeMinutes: 3600
InstanceType:
Ref: EksWorkshopC9InstanceType
SubnetId: !If [ IsCloud9SubnetSpecified, !Ref Cloud9Subnet, !Ref "AWS::NoValue" ]
Name: !If [ IsCloud9NotNamed, !Ref AWS::StackName, !Ref Cloud9Name ]
OwnerArn: !If [ Create3rdPartyResources, !Ref WorkshopOwnerArn, !Ref "AWS::NoValue" ]
Tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- nlb.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- nlb.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- nlb.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
# HIGHLIGHT
patches:
# HIGHLIGHT
- deployment-patch.yaml
- path: deployment-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../provisioner
patches:
- provisioner.yaml
- path: provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- hpa.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../nlb
patches:
- nlb.yaml
- path: nlb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: Kustomization
bases:
- ../checkout
patches:
- checkout-redis.yaml
- checkout.yaml
- path: checkout-redis.yaml
- path: checkout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../../base-application/checkout/
patches:
- checkout.yaml
- path: checkout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../../base-application/checkout
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../sizing
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../enabling
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../../../base-application/ui
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../../../base-application/ui
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- efspvclaim.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ bases:
resources:
- fsxnpvclaim.yaml
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../base-application/checkout
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../../base-application/checkout/
patches:
- checkout.yaml
- path: checkout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ vars:
fieldref:
fieldpath: data.CATALOG_RDS_PASSWORD
patches:
- catalog-configMap.yaml
- secrets.yaml
- path: catalog-configMap.yaml
- path: secrets.yaml
resources:
- nlb.yaml
configurations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: checkoutv2
resources:
- ../../../../base-application/checkout
patches:
- deploymentv2.yaml
- servicev2.yaml
- delete-deployment-redis.yaml
- delete-service-redis.yaml
- path: deploymentv2.yaml
- path: servicev2.yaml
- path: delete-deployment-redis.yaml
- path: delete-service-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ vars:
fieldref:
fieldpath: data.CARTS_IAM_ROLE
patches:
- carts-serviceAccount.yaml
- path: carts-serviceAccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: Kustomization
bases:
- ../base
patches:
- namespace.yaml
- deployment.yaml
- path: namespace.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../base
patches:
- namespace.yaml
- path: namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../base
patches:
- deployment.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../base
patches:
- namespace.yaml
- path: namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: Kustomization
bases:
- ../base
patches:
- namespace.yaml
- deployment.yaml
- path: namespace.yaml
- path: deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: Kustomization
bases:
- ../../../base-application/catalog
patches:
- deployment.yaml
- path: deployment.yaml
5 changes: 2 additions & 3 deletions test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ FROM eks-workshop-environment

USER root

RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash - && \
yum install -y nodejs npm aws-cli procps && \
yum clean all
RUN yum install https://rpm.nodesource.com/pub_16.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y && \
yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1

WORKDIR /app

Expand Down
1 change: 1 addition & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock

0 comments on commit 3c92958

Please sign in to comment.