From f9bbef2a3062610d753f6214aa16fe650336d878 Mon Sep 17 00:00:00 2001 From: nareunhang Date: Tue, 26 Nov 2024 17:38:44 +0900 Subject: [PATCH] =?UTF-8?q?#106=20Feat:=20Ec2=20API=20=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=EC=9D=98=20=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Features/Instance/table/EC2Table.jsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/aiwa-mcp-frontend/src/Console/Features/Instance/table/EC2Table.jsx b/aiwa-mcp-frontend/src/Console/Features/Instance/table/EC2Table.jsx index 030a460..8209a78 100644 --- a/aiwa-mcp-frontend/src/Console/Features/Instance/table/EC2Table.jsx +++ b/aiwa-mcp-frontend/src/Console/Features/Instance/table/EC2Table.jsx @@ -17,7 +17,7 @@ function EC2Table() { const [allEC2s, setAllEC2s] = useState([]); const [displayedEC2s, setDisplayedEC2s] = useState([]); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); - const { currentUser, selectedCompany } = useUserContext(); + const { currentUser, selectedCompany, projectId, accessKey } = useUserContext(); const openDeleteModal = () => setIsDeleteModalOpen(true); const closeDeleteModal = () => setIsDeleteModalOpen(false); @@ -25,13 +25,18 @@ function EC2Table() { const fetchEC2AndGCPData = async () => { try { const [ec2Response, gcpResponse] = await Promise.all([ - axios.get( - `${AWS_API_URL}/ec2/describe?userId=${currentUser.id}&companyName=${selectedCompany}` - ), - axios.get( - `${GCP_API_URL}/vm/describe?projectId=eighth-service-439605-r6&userId=${currentUser.id}` - ), + accessKey + ? axios.get( + `${AWS_API_URL}/ec2/describe?userId=${currentUser.id}&companyName=${selectedCompany}` + ) + : Promise.resolve({data: {}}), + projectId + ? axios.get( + `${GCP_API_URL}/vm/describe?projectId=${projectId}&userId=${currentUser.id}` + ) + : Promise.resolve({ data: {} }), // projectId가 없으면 빈 객체를 담은 resolved Promise 반환 ]); + console.log(projectId); // EC2 데이터 처리 const processedEC2s =