-
Notifications
You must be signed in to change notification settings - Fork 0
OT-14 chore setup terraform and cicd #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
853ab90
cb4d1e7
97608ad
23aed85
7061e4c
3e12138
c456878
b254580
4abe536
d6cd836
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,10 @@ on: | |
| types: | ||
| - closed | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| env: | ||
| AWS_REGION: ap-northeast-2 | ||
| SERVICE_NAME: machine | ||
|
|
@@ -28,8 +32,7 @@ jobs: | |
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Login to ECR | ||
|
|
@@ -73,16 +76,16 @@ jobs: | |
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Deploy AI service to EC2 via SSM | ||
| env: | ||
| ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com | ||
| IMAGE_TAG_INPUT: ${{ github.event.inputs.image_tag }} | ||
| PROJECT_NAME: oplust | ||
| SSM_MACHINE_ENV_PARAM: /oplust/machine/env | ||
| ENV_NAME: dev | ||
| SSM_MACHINE_ENV_PARAM: /oplust/dev/machine/env | ||
| SSM_MACHINE_NODE_EXPORTER_TARGET_PARAM: /oplust/monitoring/targets/machine-node-exporter | ||
| run: | | ||
| set -euo pipefail | ||
|
|
@@ -96,12 +99,12 @@ jobs: | |
|
|
||
| MONITORING_PRIVATE_IP=$(aws ec2 describe-instances \ | ||
| --region "$AWS_REGION" \ | ||
| --filters "Name=tag:Name,Values=${PROJECT_NAME}-monitoring-ec2" "Name=instance-state-name,Values=running" \ | ||
| --filters "Name=tag:Name,Values=monitoring" "Name=tag:Project,Values=${PROJECT_NAME}" "Name=tag:Env,Values=${ENV_NAME}" "Name=instance-state-name,Values=running" \ | ||
| --query "Reservations[0].Instances[0].PrivateIpAddress" \ | ||
| --output text) | ||
|
Comment on lines
100
to
104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งฉ Analysis chain๐ Script executed: cat -n .github/workflows/deploy-ai.yml | sed -n '95,160p'Repository: OpenTheTaste/backend Length of output: 3433 ๋ชจ๋ํฐ๋ง ์ธ์คํด์ค๋ ID๋ก ๋จผ์ ๊ฒฐ์ ํ ์ฌ์ฌ์ฉํ์ธ์. lines 100-104์ 148-152์์ ๋์ผํ ํํฐ๋ก ๋ชจ๋ํฐ๋ง ์ธ์คํด์ค ID๋ฅผ ๋จผ์ 1ํ ์กฐํ๋ก ๊ฒฐ์ ํ ํ, ๊ทธ ID๋ก private IP์ SG๋ฅผ ๋ชจ๋ ์ฝ์ด์ค์ธ์. (MACHINE_INSTANCE์ ํจํด์ ์ฐธ๊ณ : lines 142-146์์ instance-ids ์ฌ์ฉ) ๐ค Prompt for AI Agents |
||
|
|
||
| if [ -z "$MONITORING_PRIVATE_IP" ] || [ "$MONITORING_PRIVATE_IP" = "None" ]; then | ||
| echo "No running monitoring instance found for tag: ${PROJECT_NAME}-monitoring-ec2" >&2 | ||
| echo "No running monitoring instance found for Name=monitoring, Project=${PROJECT_NAME}, Env=${ENV_NAME}" >&2 | ||
| exit 1 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| fi | ||
|
|
||
|
|
@@ -116,6 +119,26 @@ jobs: | |
| exit 1 | ||
| fi | ||
|
|
||
| wait_for_ssm_online() { | ||
| local iid="$1" | ||
| for _ in $(seq 1 30); do | ||
| ping_status=$(aws ssm describe-instance-information \ | ||
| --region "$AWS_REGION" \ | ||
| --filters "Key=InstanceIds,Values=${iid}" \ | ||
| --query 'InstanceInformationList[0].PingStatus' \ | ||
| --output text 2>/dev/null || true) | ||
| if [ "$ping_status" = "Online" ]; then | ||
| return 0 | ||
| fi | ||
| sleep 5 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| if ! wait_for_ssm_online "$INSTANCE_ID"; then | ||
| echo "Instance is running but not SSM Online: $INSTANCE_ID" >&2 | ||
| exit 1 | ||
| fi | ||
| MACHINE_PRIVATE_IP=$(aws ec2 describe-instances \ | ||
| --region "$AWS_REGION" \ | ||
| --instance-ids "$INSTANCE_ID" \ | ||
|
|
@@ -124,7 +147,7 @@ jobs: | |
|
|
||
| MONITORING_SG_ID=$(aws ec2 describe-instances \ | ||
| --region "$AWS_REGION" \ | ||
| --filters "Name=tag:Name,Values=${PROJECT_NAME}-monitoring-ec2" "Name=instance-state-name,Values=running" \ | ||
| --filters "Name=tag:Name,Values=monitoring" "Name=tag:Project,Values=${PROJECT_NAME}" "Name=tag:Env,Values=${ENV_NAME}" "Name=instance-state-name,Values=running" \ | ||
| --query "Reservations[0].Instances[0].SecurityGroups[0].GroupId" \ | ||
| --output text) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐งฉ Analysis chain
๐ Script executed:
cat -n .github/workflows/deploy-ai.yml | head -100Repository: OpenTheTaste/backend
Length of output: 4350
๐ Script executed:
Repository: OpenTheTaste/backend
Length of output: 4593
๐ Web query:
aws-actions configure-aws-credentials@v4 default role-duration-seconds OIDC session๐ก Result:
In the aws-actions/configure-aws-credentials action (including v4), the role-duration-seconds input controls the duration of the assumed role session in seconds [1][2]. Key details regarding this setting include: Default Value: The default duration is 1 hour (3600 seconds) [1][3]. Configurability: You can adjust this value by providing an integer to the role-duration-seconds input [1][3]. Constraints: The requested duration cannot exceed the MaxSessionDuration setting configured for the specific IAM Role in AWS [1][4]. Acceptable values generally range from 15 minutes (900 seconds) to 12 hours (43200 seconds), depending on the IAM role's configuration [3][5]. OIDC Context: When using OIDC to assume a role, the same 1-hour default applies [6][7]. If you require a session longer than 1 hour, you must explicitly set role-duration-seconds to your desired value (up to the role's maximum) [6]. If you encounter an error stating that the requested duration exceeds the maximum, ensure that the IAM Role's MaxSessionDuration in the AWS console or via CLI/API is set high enough to accommodate your requested duration [4][5].
Citations:
OIDC ์ธ์ ๊ธธ์ด๋ฅผ ๋ฐฐํฌ ์ต๋ ์๊ฐ์ ๋ง์ถฐ ๋ช ์ํด์ผ ํฉ๋๋ค.
ํ์ฌ
configure-aws-credentials์ก์ ์ ๊ธฐ๋ณธ OIDC ์ธ์ ๊ธฐ๊ฐ์ 3,600์ด(1์๊ฐ)์ด์ง๋ง, ๋ผ์ธ 235์ SSM ๋ช ๋ น ํ์์์์ 7,200์ด์ด๊ณ ๋ผ์ธ 244-270์ ํด๋ง ๋ฃจํ๋ ์ต๋ 7,200์ด๊น์ง ์ง์๋ฉ๋๋ค. ์ด ๊ฒฝ์ฐ ๋ฐฐํฌ๊ฐ 1์๊ฐ์ ์ด๊ณผํ๋ฉด ๋ผ์ธ 245, 259, 273์ AWS API ํธ์ถ์ดExpiredToken์ค๋ฅ๋ก ์คํจํฉ๋๋ค.role-duration-seconds๋ฅผ 7,200์ด ์ด์์ผ๋ก ์ค์ ํ๊ณ , ํด๋น IAM ์ญํ ์MaxSessionDuration์ด ์ถฉ๋ถํ ๊ตฌ์ฑ๋์ด ์๋์ง ํ์ธํ์ธ์.๐ค Prompt for AI Agents