Skip to content

Commit 0e6d0cd

Browse files
authored
[수정] aws config 분리 및 버킷 생성 기능 추가 (#16)
1 parent 6789d3f commit 0e6d0cd

File tree

6 files changed

+204
-244
lines changed

6 files changed

+204
-244
lines changed

docs/docs.go

+27-63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger.json

+27-63
Original file line numberDiff line numberDiff line change
@@ -16,75 +16,39 @@
1616
},
1717
"basePath": "/api",
1818
"paths": {
19+
"/v1/s3/download": {
20+
"get": {
21+
"responses": {}
22+
}
23+
},
24+
"/v1/s3/upload": {
25+
"post": {
26+
"responses": {}
27+
}
28+
},
29+
"/v1/terraform/apply": {
30+
"post": {
31+
"responses": {}
32+
}
33+
},
34+
"/v1/terraform/merge": {
35+
"post": {
36+
"responses": {}
37+
}
38+
},
39+
"/v1/user/key": {
40+
"post": {
41+
"responses": {}
42+
}
43+
},
1944
"/v1/user/sign/in": {
2045
"post": {
21-
"description": "Auth user and return access and refresh token.",
22-
"consumes": [
23-
"application/json"
24-
],
25-
"produces": [
26-
"application/json"
27-
],
28-
"tags": [
29-
"User"
30-
],
31-
"summary": "auth user and return access and refresh token",
32-
"parameters": [
33-
{
34-
"description": "User Email",
35-
"name": "email",
36-
"in": "body",
37-
"required": true,
38-
"schema": {
39-
"type": "string"
40-
}
41-
},
42-
{
43-
"description": "User Password",
44-
"name": "password",
45-
"in": "body",
46-
"required": true,
47-
"schema": {
48-
"type": "string"
49-
}
50-
}
51-
],
52-
"responses": {
53-
"200": {
54-
"description": "ok",
55-
"schema": {
56-
"type": "string"
57-
}
58-
}
59-
}
46+
"responses": {}
6047
}
6148
},
6249
"/v1/user/sign/out": {
6350
"post": {
64-
"security": [
65-
{
66-
"ApiKeyAuth": []
67-
}
68-
],
69-
"description": "De-authorize user and delete refresh token from Redis.",
70-
"consumes": [
71-
"application/json"
72-
],
73-
"produces": [
74-
"application/json"
75-
],
76-
"tags": [
77-
"User"
78-
],
79-
"summary": "de-authorize user and delete refresh token from Redis",
80-
"responses": {
81-
"204": {
82-
"description": "ok",
83-
"schema": {
84-
"type": "string"
85-
}
86-
}
87-
}
51+
"responses": {}
8852
}
8953
}
9054
},

docs/swagger.yaml

+17-41
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,27 @@ info:
1111
title: API
1212
version: "1.0"
1313
paths:
14+
/v1/s3/download:
15+
get:
16+
responses: {}
17+
/v1/s3/upload:
18+
post:
19+
responses: {}
20+
/v1/terraform/apply:
21+
post:
22+
responses: {}
23+
/v1/terraform/merge:
24+
post:
25+
responses: {}
26+
/v1/user/key:
27+
post:
28+
responses: {}
1429
/v1/user/sign/in:
1530
post:
16-
consumes:
17-
- application/json
18-
description: Auth user and return access and refresh token.
19-
parameters:
20-
- description: User Email
21-
in: body
22-
name: email
23-
required: true
24-
schema:
25-
type: string
26-
- description: User Password
27-
in: body
28-
name: password
29-
required: true
30-
schema:
31-
type: string
32-
produces:
33-
- application/json
34-
responses:
35-
"200":
36-
description: ok
37-
schema:
38-
type: string
39-
summary: auth user and return access and refresh token
40-
tags:
41-
- User
31+
responses: {}
4232
/v1/user/sign/out:
4333
post:
44-
consumes:
45-
- application/json
46-
description: De-authorize user and delete refresh token from Redis.
47-
produces:
48-
- application/json
49-
responses:
50-
"204":
51-
description: ok
52-
schema:
53-
type: string
54-
security:
55-
- ApiKeyAuth: []
56-
summary: de-authorize user and delete refresh token from Redis
57-
tags:
58-
- User
34+
responses: {}
5935
securityDefinitions:
6036
ApiKeyAuth:
6137
in: header

pkg/configs/aws_config.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package configs
2+
3+
import (
4+
"context"
5+
"os"
6+
7+
"github.com/aws/aws-sdk-go-v2/config"
8+
"github.com/aws/aws-sdk-go-v2/credentials"
9+
"github.com/aws/aws-sdk-go-v2/service/s3"
10+
)
11+
12+
type AWSConfig struct {
13+
AccessKey string
14+
SecretKey string
15+
Region string
16+
}
17+
18+
func GetAWSConfig() AWSConfig {
19+
return AWSConfig{
20+
AccessKey: os.Getenv("AWS_ACCESS_KEY"),
21+
SecretKey: os.Getenv("AWS_SECRET_KEY"),
22+
Region: os.Getenv("AWS_REGION"),
23+
}
24+
}
25+
26+
func GetS3Client() *s3.Client {
27+
cfg, err := config.LoadDefaultConfig(context.TODO(),
28+
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(GetAWSConfig().AccessKey, GetAWSConfig().SecretKey, "")),
29+
config.WithRegion(GetAWSConfig().Region),
30+
)
31+
if err != nil {
32+
return nil
33+
}
34+
35+
return s3.NewFromConfig(cfg)
36+
}

platform/amazon/amazon.go

-77
This file was deleted.

0 commit comments

Comments
 (0)