A comprehensive PowerShell script that provides detailed insights into your Google Cloud Platform (GCP) resources, including real-time cost analysis with multi-currency support.
-
๐ Complete Resource Inventory
- GKE Clusters and Kubernetes workloads
- Compute instances (VMs/Nodes) with detailed specifications
- Network resources (VPC, Subnets, Load Balancers, Firewall rules)
- Storage resources (Persistent Disks, Cloud Storage, PVCs)
-
๐ฐ Real-Time Cost Analysis
- Automatic USD to INR currency conversion using live exchange rates
- Detailed cost breakdown by resource type
- Monthly, daily, and hourly cost projections
- Free trial credit burn rate calculation
-
๐ Resource Utilization Metrics
- CPU and memory allocation tracking
- Node resource usage monitoring
- Available vs allocated resources visualization
-
๐ Access Guide
- External IP addresses and connection endpoints
- kubectl commands for cluster access
- Load balancer access URLs with curl examples
- Direct links to GCP Console
-
๐ณ Billing Information
- Billing account status and details
- Free trial timeline tracking
- Budget alert threshold configuration
- Days since project creation
Before running this script, ensure you have:
- Google Cloud SDK (
gcloud) installed and authenticated - kubectl installed and configured (for GKE cluster analysis)
- PowerShell 5.1+ (Windows) or PowerShell Core 7+ (Linux/macOS)
- Active GCP project with appropriate IAM permissions
- Internet connection (for live exchange rate API)
Your account needs the following IAM roles:
roles/viewer(Project-level read access)roles/container.viewer(GKE cluster access)roles/billing.viewer(Billing information access)
- git clone https://github.com/rajmohanacharya/gcp-resource-summary-cost-analysis-powershell-script.git
- cd gcp-resource-summary
Download the Get-GCPResourceSummary.ps1 file directly from this repository.
.\Get-GCPResourceSummary.ps1
If you are planning to run this script on your Corporate laptop/desktop, it might fail with restrictions error message As a workaround, you can copy the full contents of the script and run it in powershell
.\Get-GCPResourceSummary.ps1 -ProjectId "my-gcp-project-123"
pwsh ./Get-GCPResourceSummary.ps1
The script generates a comprehensive report with the following sections:
-
GCP Project & Billing Information
- Project ID, Number, Name
- High-level resource count
- Billing account details
- Free trial status and timeline
- Budget alerts configuration
-
GKE Cluster Details
- Cluster name, location, and status
- Kubernetes version information
- Node count and configuration
-
Compute Resources
- Node specifications (CPU, Memory, Disk)
- IP addresses (Internal and External)
- Container runtime details
- Pods running per node
-
Network Resources
- VPC networks and subnets
- Cloud NAT configuration
- Firewall rules
- Load balancers with ports
- External IP addresses
-
Storage Resources
- Persistent disks
- Cloud Storage buckets
- Kubernetes PVCs
-
Kubernetes Workloads
- Pods, Deployments, Services count
- Pod status and resource requests
-
Resource Utilization
- CPU and memory allocation
- Available resources
-
Cost Analysis
- Compute, storage, and network costs
- USD and INR pricing
- Monthly, daily, hourly projections
- Free trial burn rate
-
Resource Access Guide
- External IP access instructions
- kubectl connection commands
- Load balancer URLs
- GCP Console quick links
To use a different exchange rate or currency, modify the API endpoint:
$response = Invoke-RestMethod -Uri "https://open.er-api.com/v6/latest/USD" $usdToInr = [math]::Round($response.rates.INR, 2)
Replace INR with your desired currency code (e.g., EUR, GBP, JPY).
Cost calculations are based on standard GCP pricing. Update these variables in the script:
$computeCostPerNode = 24.50 # e2-medium cost $diskCostPerGB = 0.040 # Standard persistent disk $lbMonthlyCost = 18.00 # Per forwarding rule
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Budget information requires
gcloud beta billingcommands - Some network metrics may not be available in all GCP regions
- Free trial detection is approximate based on project creation date
If you encounter any issues or have questions:
- Open an Issue
- Check existing Discussions
- Exchange rate data provided by ExchangeRate-API
- Inspired by GCP cost management best practices
- Community feedback and contributions
- Google Cloud SDK Documentation
- GCP Pricing Calculator
- Kubernetes Documentation
- PowerShell Documentation
โญ If you find this script helpful, please consider giving it a star!