jueves, 4 de diciembre de 2025

Terraform list block

 A way to query for bunch of resources.

Create a file name.tfquery.hcl :

list "aws_instance" "aws_instances" {
provider = aws
limit = 50
config {
region = "us-east-1"
}
}


 

Then run:

terraform query
Warning: list block(s) [list.aws_instance.APIGateways] returned 0 results.

The supported resource types:

terraform providers schema -json 2>/dev/null | jq -r '.provider_schemas."registry.terraform.io/hashicorp/aws".list_resource_schemas | keys[]' | sort
aws_batch_job_queue
aws_cloudwatch_log_group
aws_iam_policy
aws_iam_role
aws_iam_role_policy_attachment
aws_instance
aws_subnet
aws_vpc 

lunes, 24 de noviembre de 2025

Delete a branch both locally and remotely



Here's how to delete a branch both locally and remotely:

Step-by-Step Deletion

Step 1: Switch to a Different Branch First

You can't delete a branch you're currently on:

# Switch to dev or main
git switch dev

Step 2: Delete Local Branch

# Delete local branch (safe delete - prevents deletion if unmerged)
git branch -d feat/-deployment

# OR force delete (if you get warnings about unmerged changes)
git branch -D feat/-deployment

Step 3: Delete Remote Branch

# Delete remote branch
git push origin --delete feat/-deployment

viernes, 14 de noviembre de 2025

AWS CLI SSO

 

To log in to AWS CLI using SSO (IAM Identity Center), follow these steps:
  • Configure your AWS CLI profile for SSO:
This step sets up the necessary configuration in your AWS CLI profile to use IAM Identity Center for authentication. You will need your SSO Start URL and SSO Region.
Código
    aws configure sso
The command will interactively prompt you for:
  • SSO Start URL: The URL for your organization's AWS access portal.
  • SSO Region: The AWS Region where your IAM Identity Center instance is located.
  • AWS Account ID: The AWS account you want to access.
  • Role Name: The IAM role (permission set) you want to assume within that account.
  • Default output format: (e.g., json, text, table)
  • Default region: The AWS Region where your commands will be sent by default.
  • Profile name: A name for this SSO profile (e.g., my-sso-profile).
To use the profile:
aws sts get-caller-identity --profile aeropay 
 
Log in to IAM Identity Center.
After configuring the profile, you need to initiate the login process to obtain temporary credentials.
Código
aws sso login --profile <your-profile-name>
export AWS_PROFILE=company-profile
 
Replace <your-profile-name> with the name you provided in the aws configure sso step. This command typically opens your default web browser to the IAM Identity Center login page, where you authenticate using your organization's credentials. Once authenticated, the AWS CLI retrieves and caches temporary credentials.
Note: If you prefer not to open a browser, you can use the --no-browser or --use-device-code options with aws sso login. Use the configured profile.
After a successful login, you can use the configured profile to execute AWS CLI commands.
Código
    aws s3 ls --profile <your-profile-name>
This command would list your S3 buckets using the credentials obtained through your SSO session.
Important Considerations:
  • AWS CLI Version:
    Ensure you are using AWS CLI version 2, as SSO integration is primarily supported in this version.
  • Session Management:
    SSO sessions have a limited duration. When your session expires, you will need to run aws sso login again to refresh your credentials.
  • Logout:
    To explicitly log out and remove cached credentials, use aws sso logout --profile <your-profile-name>