빠른 시작 가이드
이 가이드는 @aws/nx-plugin을 설치하고 사용하여 AWS에서 프로젝트를 빠르게 구축하는 기본 사항을 안내합니다.
사전 요구 사항
섹션 제목: “사전 요구 사항”진행하기 전에 다음 전역 종속성이 필요합니다:
- Git
- Node >= 22 (NVM과 같은 도구를 사용하여 node 버전을 관리하는 것을 권장합니다)
node --version을 실행하여 확인하세요
- UV >= 0.5.29
uv python install 3.14를 실행하여 Python 3.14를 설치하세요uv python list --only-installed로 확인하세요
- PNPM >= 11 (원하는 경우 Yarn >= 4, Bun >= 1, 또는 NPM >= 11을 사용할 수도 있습니다)
pnpm --version,yarn --version,bun --version또는npm --version을 실행하여 확인하세요
- 애플리케이션을 배포하려면 (일부 로컬 개발 워크플로에도 필요) 대상 AWS 계정에 구성된 AWS Credentials가 필요합니다.
- 일부 생성기에는 Docker 또는 Finch >= 1.6.0이 필요합니다. Docker의 경우 멀티 플랫폼 빌드가 설정되어 있어야 하며, Finch는 기본적으로 멀티 플랫폼 빌드를 지원합니다.
- CDK 대신 인프라를 코드로 관리하기 위해 이것을 사용하려면 Terraform >= 1.12가 필요합니다
terraform --version을 실행하여 확인하세요
- VSCode를 사용하는 경우 Nx Console VSCode Plugin 설치를 권장합니다.
1단계: 워크스페이스 생성
섹션 제목: “1단계: 워크스페이스 생성”원하는 패키지 매니저로 Nx 워크스페이스를 생성하고, 생성된 디렉터리를 엽니다:
워크스페이스 생성@aws/nx-workspace
pnpm create @aws/nx-workspace my-project yarn create @aws/nx-workspace my-project npm create @aws/nx-workspace -- my-project bun create @aws/nx-workspace my-project명령 구성하기3
필수
cd my-project코드형 인프라 제공자로 CDK 또는 Terraform 중 하나를 선택하라는 메시지가 표시됩니다.
2단계: 애플리케이션 빌드
섹션 제목: “2단계: 애플리케이션 빌드”풀스택 애플리케이션을 빌드합니다: tRPC API, React 웹사이트, Cognito 인증, 그리고 CDK 또는 Terraform 인프라. AI 어시스턴트에게 스캐폴딩을 요청하거나 제너레이터를 직접 실행하세요 — 두 방법 모두 동일한 워크스페이스에 도달합니다.
AI 사용
섹션 제목: “AI 사용”-
AI 코딩 어시스턴트에서 워크스페이스를 엽니다.
새 워크스페이스에는 플러그인의 MCP server가 Kiro, Claude Code, Cursor, Gemini CLI, GitHub Copilot 및 OpenAI Codex에 대해 이미 구성되어 있으므로, 어시스턴트가 별도의 설정 없이 플러그인의 제너레이터를 조회하고 실행할 수 있습니다.
-
애플리케이션을 요청합니다:
Prompt Create a tRPC API called demo-api, and a React website called demo-website. Add Cognito authentication to the website, connect the website to the API, and add an infrastructure project called infra. Then instantiate the generated infrastructure components so the website and API deploy, granting authenticated users access to the API.
어시스턴트는 MCP 서버를 통해 제너레이터를 발견하고 종속성이 필요한 순서대로 실행합니다. 변경 사항을 검토한 다음 3단계로 계속 진행하세요.
CLI 사용
섹션 제목: “CLI 사용”애플리케이션을 스캐폴딩하는 제너레이터를 실행합니다. 아래 버튼을 사용하여 모두 복사하거나, 다이어그램 아래에 설명된 대로 각각을 직접 실행하세요.
구축하는 프로젝트 유형에 따라 제너레이터의 조합을 선택하여 프로젝트를 빠르게 부트스트랩할 수 있습니다. 왼쪽 탐색 바의 __Generators__를 확인하여 전체 옵션 목록을 보거나, 그래프 빌더를 사용하여 워크스페이스를 시각적으로 구성해 보세요.
tRPC API 추가
섹션 제목: “tRPC API 추가”이 제너레이터 실행@aws/nx-plugin:ts#api
pnpm nx g @aws/nx-plugin:ts#api --no-interactive yarn nx g @aws/nx-plugin:ts#api --no-interactive npx nx g @aws/nx-plugin:ts#api --no-interactive bunx nx g @aws/nx-plugin:ts#api --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - ts#api - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션2
필수
이렇게 하면 packages/demo-api 폴더 내에 API가 생성됩니다.
React 웹사이트 추가
섹션 제목: “React 웹사이트 추가”이 제너레이터 실행@aws/nx-plugin:ts#website
pnpm nx g @aws/nx-plugin:ts#website --no-interactive yarn nx g @aws/nx-plugin:ts#website --no-interactive npx nx g @aws/nx-plugin:ts#website --no-interactive bunx nx g @aws/nx-plugin:ts#website --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - ts#website - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션1
필수
이렇게 하면 packages/demo-website에 새 React 웹사이트가 스캐폴딩됩니다.
Cognito 인증 추가
섹션 제목: “Cognito 인증 추가”이 제너레이터 실행@aws/nx-plugin:ts#website#auth
pnpm nx g @aws/nx-plugin:ts#website#auth --no-interactive yarn nx g @aws/nx-plugin:ts#website#auth --no-interactive npx nx g @aws/nx-plugin:ts#website#auth --no-interactive bunx nx g @aws/nx-plugin:ts#website#auth --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - ts#website#auth - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션1
필수
이렇게 하면 웹사이트에 Cognito 인증을 추가하는 데 필요한 인프라와 React 코드가 설정됩니다.
프론트엔드와 백엔드 연결
섹션 제목: “프론트엔드와 백엔드 연결”이 제너레이터 실행@aws/nx-plugin:connection
pnpm nx g @aws/nx-plugin:connection --no-interactive yarn nx g @aws/nx-plugin:connection --no-interactive npx nx g @aws/nx-plugin:connection --no-interactive bunx nx g @aws/nx-plugin:connection --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - connection - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션2
필수
필수
이렇게 하면 웹사이트가 tRPC API를 호출할 수 있도록 필요한 프로바이더가 구성됩니다.
인프라 추가
섹션 제목: “인프라 추가”선택한 IAC 제공자에 따라 인프라 프로젝트를 추가합니다.
이 제너레이터 실행@aws/nx-plugin:ts#infra
pnpm nx g @aws/nx-plugin:ts#infra --no-interactive yarn nx g @aws/nx-plugin:ts#infra --no-interactive npx nx g @aws/nx-plugin:ts#infra --no-interactive bunx nx g @aws/nx-plugin:ts#infra --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - ts#infra - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션1
필수
이렇게 하면 AWS에 인프라를 배포하는 데 사용할 수 있는 CDK 앱이 구성됩니다.
이 제너레이터 실행@aws/nx-plugin:terraform#project
pnpm nx g @aws/nx-plugin:terraform#project --no-interactive yarn nx g @aws/nx-plugin:terraform#project --no-interactive npx nx g @aws/nx-plugin:terraform#project --no-interactive bunx nx g @aws/nx-plugin:terraform#project --no-interactive- 설치 Nx Console VSCode Plugin 아직 설치하지 않았다면
- VSCode에서 Nx 콘솔 열기
- 클릭
Generate (UI)"Common Nx Commands" 섹션에서 - 검색
@aws/nx-plugin - terraform#project - 필수 매개변수 입력
- 클릭
Generate
이 단계의 옵션1
필수
이렇게 하면 AWS에 인프라를 배포하는 데 사용할 수 있는 Terraform 프로젝트가 구성됩니다.
3단계: 웹사이트와 API를 로컬에서 실행
섹션 제목: “3단계: 웹사이트와 API를 로컬에서 실행”다음 명령을 사용하여 웹사이트와 연결된 API에 대한 로컬 개발 서버를 시작합니다:
pnpm devyarn devnpm run devbun dev웹사이트는 http://localhost:4200에서 사용할 수 있습니다.
로컬 웹사이트와 API 서버가 모두 핫 리로드되므로 웹사이트와 API 모두의 변경 사항이 실시간으로 반영됩니다.
웹사이트에서 API 호출하기
웹사이트를 API에 연결하면 useDemoApi 훅이 추가되며, 이는 tRPC options proxy를 반환합니다: API의 모든 프로시저는 TanStack Query에 전달할 queryOptions와 mutationOptions를 제공합니다.
packages/demo-website/src/routes/index.tsx를 업데이트하여 API의 echo 프로시저를 호출하고, 요청이 진행 중일 때 스피너를 표시합니다:
import { useQuery } from '@tanstack/react-query';import { createFileRoute } from '@tanstack/react-router';import { Spinner } from '../components/spinner';import { useDemoApi } from '../hooks/useDemoApi';
export const Route = createFileRoute('/')({ component: RouteComponent,});
function RouteComponent() { const trpc = useDemoApi(); const echo = useQuery( trpc.echo.queryOptions({ message: 'Hello from the API!' }), );
return ( <div className="text-center"> <header> <h1>Welcome</h1> <p>Welcome to your new React website!</p> </header> {echo.isLoading ? ( <Spinner /> ) : echo.error ? ( <p>Error: {echo.error.message}</p> ) : ( <p>{echo.data?.message}</p> )} </div> );}파일을 저장하면 API가 에코한 메시지와 함께 페이지가 다시 로드됩니다. 호출은 엔드 투 엔드로 타입 안전합니다 — packages/demo-api/src/schema/echo.ts에서 message의 이름을 변경하면 변경 사항을 따라갈 때까지 웹사이트 컴파일이 중지됩니다.
뮤테이션, 구독, 오류 처리 및 낙관적 업데이트에 대해서는 React to tRPC connection guide를 참조하세요.
4단계: 클라우드 리소스 정의 및 AWS에 배포
섹션 제목: “4단계: 클라우드 리소스 정의 및 AWS에 배포”packages/infra/src/stacks/application-stack.ts를 열고 다음 코드를 추가합니다:
import { DemoApi, DemoWebsite, UserIdentity,} from '@my-project/common-constructs';import { Stack, StackProps } from 'aws-cdk-lib';import { Construct } from 'constructs';
export class ApplicationStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props);
const identity = new UserIdentity(this, 'identity'); const api = new DemoApi(this, 'api', { integrations: DemoApi.defaultIntegrations(this).build(), }); api.grantInvokeAccess(identity.identityPool.authenticatedRole);
new DemoWebsite(this, 'website'); }}이것이 풀스택 애플리케이션을 배포하기 위해 작성해야 하는 모든 CDK 코드입니다.
packages/infra/src/main.tf를 열고 다음 코드를 추가합니다:
# Deploy user identitymodule "user_identity" { source = "../../common/terraform/src/core/user-identity"}
# Shared asset bucket — stages Lambda deployment zips for every lambda / API modulemodule "asset_bucket" { source = "../../common/terraform/src/core/asset-bucket"}
# Deploy APImodule "demo_api" { source = "../../common/terraform/src/app/apis/demo-api"
asset_bucket_name = module.asset_bucket.bucket_name}
# Grant authenticated users access to invoke the APIresource "aws_iam_policy" "api_invoke_policy" { name = "DemoApiInvokePolicy" description = "Policy to allow authenticated users to invoke the API"
policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = "execute-api:Invoke" Resource = "${module.demo_api.api_execution_arn}/*/*" } ] })}
resource "aws_iam_role_policy_attachment" "authenticated_api_access" { role = module.user_identity.authenticated_role_name policy_arn = aws_iam_policy.api_invoke_policy.arn}
# Deploy websiteprovider "aws" { alias = "us_east_1" region = "us-east-1"}
module "demo_website" { source = "../../common/terraform/src/app/static-websites/demo-website"
providers = { aws.us_east_1 = aws.us_east_1 }
depends_on = [module.user_identity, module.demo_api]}
# Print the website URL and user pool id when the deployment finishesoutput "website_url" { value = module.demo_website.website_url}
output "user_pool_id" { value = module.user_identity.user_pool_id}이것이 풀스택 애플리케이션을 배포하기 위해 작성해야 하는 모든 Terraform 코드입니다.
인프라 빌드 및 배포
섹션 제목: “인프라 빌드 및 배포”다음으로, 다음 명령을 실행하여 프로젝트를 빌드합니다:
pnpm buildyarn buildnpm run buildbun build인프라를 부트스트랩합니다:
pnpm nx bootstrap infrayarn nx bootstrap infranpx nx bootstrap infrabunx nx bootstrap infrapnpm nx bootstrap infrayarn nx bootstrap infranpx nx bootstrap infrabunx nx bootstrap infra프로젝트를 배포합니다:
pnpm nx deploy-sandbox infrayarn nx deploy-sandbox infranpx nx deploy-sandbox infrabunx nx deploy-sandbox infrapnpm nx apply infrayarn nx apply infranpx nx apply infrabunx nx apply infra5단계: 배포된 클라우드 리소스로 웹사이트 테스트
섹션 제목: “5단계: 배포된 클라우드 리소스로 웹사이트 테스트”-
runtime-config.json파일을 가져옵니다:Terminal window pnpm nx load-runtime-config demo-websiteTerminal window yarn nx load-runtime-config demo-websiteTerminal window npx nx load-runtime-config demo-websiteTerminal window bunx nx load-runtime-config demo-website -
로컬 웹사이트 서버를 시작합니다
Terminal window pnpm nx serve demo-websiteTerminal window yarn nx serve demo-websiteTerminal window npx nx serve demo-websiteTerminal window bunx nx serve demo-website
웹사이트는 http://localhost:4200에서 사용할 수 있으며, API 및 인증을 위해 배포한 리소스를 가리킵니다.
로그인하려면 Cognito 사용자 풀에서 사용자를 생성해야 합니다.
AWS CLI로 사용자 생성하기
다음 명령은 사용자 풀에 사용자를 생성합니다. 배포 출력 또는 Amazon Cognito 콘솔에서 사용자 풀 ID를 찾을 수 있습니다. 사용자 이름, 이메일, 이름과 성, 그리고 임시 비밀번호에 대한 값을 대체하세요.
aws cognito-idp admin-create-user \ --user-pool-id <user pool id> \ --username <username> \ --user-attributes Name=email,Value=<email> Name=email_verified,Value=true Name=given_name,Value=<first name> Name=family_name,Value=<last name> \ --temporary-password '<temporary password>' \ --message-action SUPPRESS이 사용자로 처음 로그인하면 새 비밀번호를 선택하라는 메시지가 표시된 다음, SMS로 전송된 코드 또는 인증 앱의 시간 기반 일회용 비밀번호를 사용하여 다단계 인증을 설정하라는 메시지가 표시됩니다.
웹사이트는 CloudFront에서도 제공됩니다. 배포 후 터미널에 출력되는 배포 도메인 이름을 열어 AWS에서 완전히 실행되는 버전을 사용하세요.
축하합니다! 🎉 @aws/nx-plugin을 사용하여 풀스택 애플리케이션을 성공적으로 빌드하고 배포했습니다!
6단계: 정리
섹션 제목: “6단계: 정리”완료되면 지속적인 비용을 피하기 위해 배포한 리소스를 삭제합니다:
pnpm nx destroy-sandbox infrayarn nx destroy-sandbox infranpx nx destroy-sandbox infrabunx nx destroy-sandbox infrapnpm nx destroy infrayarn nx destroy infranpx nx destroy infrabunx nx destroy infra부트스트랩 리소스를 제거하려면 아래를 따르세요:
us-east-1을 포함하여 부트스트랩한 모든 리전에서 부트스트랩 스택을 삭제합니다. 이렇게 하면 부트스트랩 역할과 컨테이너 이미지 리포지토리가 제거됩니다:
aws cloudformation delete-stack --stack-name CDKToolkit --region <region>pnpm nx bootstrap-destroy infrayarn nx bootstrap-destroy infranpx nx bootstrap-destroy infrabunx nx bootstrap-destroy infra다음 단계
섹션 제목: “다음 단계”- Dungeon Adventure Tutorial — 이 가이드보다 더 심화된 연습을 위해 풀스택 AI 던전 어드벤처 게임을 빌드합니다.
- Workspaces — 워크스페이스가 어떻게 배치되어 있는지, 그리고 제너레이터가 공유하는 구성에 대해 알아봅니다.
- Add to an Existing Project — 기존 코드베이스에 플러그인을 도입합니다.