# EC2 UserData output log
/var/log/cloud-init-output.log
## cfn-init
## Logs go to /var/log/cfn-init.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
pre_build: | |
commands: | |
- echo Logging in to Amazon ECR... | |
- aws --version | |
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) | |
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) | |
- IMAGE_TAG=${COMMIT_HASH} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as ec2 from '@aws-cdk/aws-ec2'; | |
import * as ecs from '@aws-cdk/aws-ecs'; | |
import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; | |
export class MyStack extends Stack { | |
constructor(scope: Construct, id: string, props: StackProps = {}) { | |
super(scope, id, props); | |
const vpc = ec2.Vpc.fromLookup(this, 'VPC', { isDefault: true }); | |
const cluster = new ecs.Cluster(this, 'Cluster', { | |
vpc, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from aws_cdk import core | |
from py_d.db_stack import DbStack | |
from py_d.lambda_stack import LambdaStack | |
env = core.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')) | |
app = core.App() | |
db = DbStack(app, "PyDStack", env=env ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as ec2 from '@aws-cdk/aws-ec2'; | |
import * as sns from '@aws-cdk/aws-sns'; | |
import * as cdk from '@aws-cdk/core'; | |
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | |
import * as cw_actions from '@aws-cdk/aws-cloudwatch-actions'; | |
export interface AlarmInstanceProps { | |
readonly UserData?: ec2.UserData; | |
readonly vpc?: ec2.IVpc; | |
readonly topic?: sns.Topic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo su - ec2-user | |
sudo yum update -y | |
sleep 15 | |
sudo yum install docker git vim -y | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash | |
env VERSION=`python tools/getnodeversion.py` make install DESTDIR=`nvm_version_path v$VERSION` PREFIX="" | |
nvm install --lts | |
npm |
import { STS, GetCallerIdentityCommandOutput } from '@aws-sdk/client-sts';
import { fromInstanceMetadata } from '@aws-sdk/credential-provider-imds';
let data: GetCallerIdentityCommandOutput;
( async ()=> {
let sts: STS;
sts = new STS({
credentials: fromInstanceMetadata({
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get update | |
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | |
apt-get update | |
apt-get install -y docker-ce-cli | |
docker version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = 0 | |
while True: | |
# Start of game? | |
if count == 0: | |
start_time = time.time() | |
num = random.randint(1, 100) | |
print "I'm thinking of a number from 1 to 100. Try to guess it! (Enter 0 to exit)" | |
# Guess a number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo amazon-linux-extras install nginx1 -y | |
sudo systemctl start nginx |