Skip to content

Commit

Permalink
b01
Browse files Browse the repository at this point in the history
  • Loading branch information
X3N064 committed Mar 7, 2024
1 parent 0f67890 commit c63514a
Show file tree
Hide file tree
Showing 27 changed files with 552 additions and 446 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.terraform*
.terraform*
terraform.*
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Photogram
AWS Photogram Project


Save ./resize and ./web to s3 bucket when it is created.
88 changes: 0 additions & 88 deletions cloudfront.tf

This file was deleted.

132 changes: 0 additions & 132 deletions ec2.tf

This file was deleted.

10 changes: 0 additions & 10 deletions elb.tf

This file was deleted.

27 changes: 0 additions & 27 deletions iam.tf

This file was deleted.

25 changes: 25 additions & 0 deletions install_terraform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#Terraform
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common

wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null


gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update

sudo apt-get install terraform

#Terraformer
export PROVIDER=all
curl -LO "https://github.com/GoogleCloudPlatform/terraformer/releases/download/$(curl -s https://api.github.com/repos/GoogleCloudPlatform/terraformer/releases/latest | grep tag_name | cut -d '"' -f 4)/terraformer-${PROVIDER}-linux-amd64"
chmod +x terraformer-${PROVIDER}-linux-amd64
sudo mv terraformer-${PROVIDER}-linux-amd64 /usr/local/bin/terraformer
12 changes: 0 additions & 12 deletions rds.tf

This file was deleted.

27 changes: 9 additions & 18 deletions resizer/app.js → resize/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ var AWS = require('aws-sdk')
, s3 = new AWS.S3({ region: 'ap-northeast-1' })
, sqs = new AWS.SQS({ region: 'ap-northeast-1' });

var s3Bucket = 'examplephoto.image';
var sqsQueueUrl = 'https://sqs.ap-northeast-1.amazonaws.com/232075047203/ExamplePhotoQueue';
var s3Bucket = 'photogram-image';
var sqsQueueUrl = 'https://sqs.ap-northeast-1.amazonaws.com/891377001852/PhotogramQueue';
var rdsEndpoint = {
host: 'examplephoto.cnlconsezo7y.ap-northeast-1.rds.amazonaws.com',
host: 'photogram.chwwmiousmy2.ap-northeast-1.rds.amazonaws.com',
port: 3306
};

// MySQL DB 이름, 계정, 암호
var sequelize = new Sequelize('examplephoto', 'admin', 'adminpassword', {
// MySQL DB Name, Account, Password
var sequelize = new Sequelize('photogram', 'admin', 'Qwer1234**', {
host: rdsEndpoint.host,
port: rdsEndpoint.port
});

// MySQL DB 테이블 정의
// MySQL DB Name Table
var Photo = sequelize.define('Photo', {
filename: { type: Sequelize.STRING, allowNull: false, unique: true }
});

// SQS 메시지 삭제
// SQS delete message
function deleteMessage(ReceiptHandle) {
sqs.deleteMessage({
QueueUrl: sqsQueueUrl,
Expand All @@ -36,16 +36,7 @@ function deleteMessage(ReceiptHandle) {
});
}

// MySQL에 데이터 저장
function insertPhoto(filename) {
sequelize.sync().success(function () {
Photo.create({
filename: filename
});
});
}

// SQS 메시지 받기
// SQS recieve message
function receiveMessage() {
sqs.receiveMessage({
QueueUrl: sqsQueueUrl,
Expand All @@ -61,7 +52,7 @@ function receiveMessage() {
});
}

// 이미지 해상도 변환
// image-resizer
function resizeImage(Message) {
var filename = Message.Body;
s3.getObject({
Expand Down
6 changes: 3 additions & 3 deletions resizer/package.json → resize/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ExamplePhotoResizeServer",
"name": "Photogram-resizer",
"version": "0.0.1",
"description": "ExamplePhotoResizeServer",
"description": "Photogram-resizer",
"dependencies": {
"aws-sdk": "2.0.x",
"aws-sdk": "2.722.x",
"mime": "1.2.x",
"sequelize": "1.7.x",
"mysql": "2.3.2",
Expand Down
Loading

0 comments on commit c63514a

Please sign in to comment.