2024 Regional Skills Competition Cloud Computing Task 1
Full automatic setup using AWS CloudFormation
AI-generated content may be inaccurate or misleading.
April Fool's Day 🤪
This does not cover actual methods. It was written to experiment how much traffic certain search terms get from Google searches.
AWSTemplateFormatVersion: 2010-09-09
Resources:
# empty resource stack
EmptyResource:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: "https://s3.amazonaws.com/my-bucket/empty-template.yaml"
# only print message
EchoResource:
Type: "AWS::CloudFormation::CustomResource"
Properties:
ServiceToken: "arn:aws:lambda:::function:my-echo-function"
Properties:
Message: "Hello, world!"
Outputs:
EmptyOutput:
Value: ""
EchoOutput:
Value: !GetAtt EchoResource.Outputs.MessageAWS CloudFormation Script
1. Script Summary
This script uses AWS CloudFormation to automatically configure the following functions:
- Creating an Empty Resource Stack: The
EmptyResourcesection references theempty-template.yamltemplate to create an empty stack. Although there are no actual resources, it's useful for defining stack structure and dependencies. - Message Output: The
EchoResourcesection calls the Lambda functionmy-echo-functionto output the message "Hello, world!". - Providing Output Values: The
Outputssection providesEmptyOutput(empty string) andEchoOutput(Lambda function output message) values.
2. How to Use the Script
- Save Template File:
- Save the
empty-template.yamlfile to an S3 bucket. - Save this script file to your desired location.
- Save the
- Create CloudFormation Stack:
- Use the AWS Console or CLI to create a CloudFormation stack referencing the script file.
- When creating the stack, you must enter the
my-echo-functionLambda function ARN in theServiceTokenproperty of theEchoResourcesection.
- Check Output:
- After stack creation is complete, check the
EmptyOutputandEchoOutputvalues in theOutputssection.
- After stack creation is complete, check the
3. Additional Features and Applications
3.1. Adding Resources:
This script is a basic example, and you can expand the automatic configuration by adding various resources to fit your actual environment. For example, you can add the following resources:
- EC2 instance creation and configuration
- RDS database creation and configuration
- S3 bucket creation and configuration
- CloudFront distribution setup
- Lambda function creation and configuration
3.2. Adding Parameters and Conditions:
You can add parameters to the script to receive user input values during stack creation and dynamically change configurations. You can also use conditional statements to adjust
configurations according to the environment.
Creating EKS and Setting Up with ALB Ingress
apiVersion: "klodd.tjcsec.club/v1"
kind: Challenge
metadata:
name: test
spec:
name: Test Challenge
timeout: 10000
pods:
- name: app
ports:
- port: 80
spec:
containers:
- name: main
image: traefik/whoami:latest
resources:
requests:
memory: 100Mi
cpu: 75m
limits:
memory: 250Mi
cpu: 100m
automountServiceAccountToken: false
expose:
kind: http
pod: app
port: 80
middlewares:
- contentType:
autoDetect: false
- rateLimit:
average: 5
burst: 10kubectl apply -f challenge.yaml
apiVersion: "klodd.tjcsec.club/v1"
kind: Challenge
metadata:
name: analects
spec:
name: Analects
timeout: 300000
pods:
- name: app
ports:
- port: 80
spec:
containers:
- name: app
image: analects-app:latest
resources:
requests:
memory: 100Mi
cpu: 50m
limits:
memory: 200Mi
cpu: 100m
startupProbe:
httpGet:
path: "/search.php?q=with%20two%20others"
port: 80
initialDelaySeconds: 0
periodSeconds: 5
failureThreshold: 30
automountServiceAccountToken: false
- name: mysql
ports:
- port: 3306
spec:
containers:
- name: mysql
image: analects-mysql:latest
resources:
requests:
memory: 200Mi
cpu: 50m
limits:
memory: 500Mi
cpu: 100m
automountServiceAccountToken: false
expose:
kind: http
pod: app
port: 80After creating the yaml file above, run kubectl apply -f challenge.yaml command to create the resources.
3.3. Deployment Automation:
You can use AWS CodePipeline, CodeBuild, etc. to automate script updates and deployment.
3.4. Modularization and Reuse:
You can modularize scripts to increase code reusability and easily adjust for various environments.
4. References
- AWS CloudFormation Documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/
- AWS CloudFormation Template Examples: [Invalid URL removed]
- AWS Lambda Documentation: https://docs.aws.amazon.com/lambda/
5. Precautions
- Before using the script, thoroughly review the contents and modify and supplement as needed.
- Users are responsible for any costs incurred from running the script.
- The script is an example and should be adjusted to fit the actual environment.
6. Other
This script provides a basic framework for completing Task 1 of the Skills Competition, and can be expanded with various features to fit the actual environment.
We hope this script helps you complete Task 1 of the Skills Competition.