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.MessageThis script uses AWS CloudFormation to automatically configure the following functions:
EmptyResource section references the empty-template.yaml template to create an empty stack. Although there are no actual resources, it's useful for defining stack structure and dependencies.EchoResource section calls the Lambda function my-echo-function to output the message "Hello, world!".Outputs section provides EmptyOutput (empty string) and EchoOutput (Lambda function output message) values.empty-template.yaml file to an S3 bucket.my-echo-function Lambda function ARN in the ServiceToken property of the EchoResource section.EmptyOutput and EchoOutput values in the Outputs section.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:
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.
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.
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.