GCP: Service Account gcloud cli

 ### Creating and Managing Service Accounts Using gcloud command-line ###

Ref Link: creating-managing-service-accounts

## Craeet Service account ##

#gcloud iam service-accounts create cmd-svc-accnt --description="Command Line Service Account" --display-name="Command Line Account" --project my-playground


## List The Service Accounts ##

#gcloud iam service-accounts list --project my-playground


## Update the Service Account ##

#gcloud iam service-accounts update  cmd-svc-accnt@my-playground.iam.gserviceaccount.com --description="Command Line Service Account" --display-name="Chamge Command Line Account"  --display-name "Change Command Line Account" --project my-playground


## Disable and Enable Service Accounts ##

#gcloud iam service-accounts disable cmd-svc-accnt@my-playground.iam.gserviceaccount.com --project my-playground

#gcloud iam service-accounts enable cmd-svc-accnt@my-playground.iam.gserviceaccount.com --project my-playground


## Grant Service account an IAM Role ##

#gcloud projects add-iam-policy-binding my-playground --member="serviceAccount:cmd-svc-accnt@my-playground.iam.gserviceaccount.com" --role="roles/editor"


## Delete the Service Account ##

#gcloud iam service-accounts delete cmd-svc-accnt@my-playground.iam.gserviceaccount.com --project my-playground


Ref Link: creating-managing-service-account-keys

## Create service account keys ##

#gcloud iam service-accounts keys create key-file.json --iam-account=cmd-svc-accnt@my-playground.iam.gserviceaccount.com


## List service account keys ##

#gcloud iam service-accounts keys list --iam-account cmd-svc-accnt@my-playground.iam.gserviceaccount.com


## Delete service account keys ##

gcloud iam service-accounts keys delete 96b194863bedad164f9d3001a128f70fd469d0a1 --iam-account cmd-svc-accnt@my-playground.iam.gserviceaccount.com

AWS IAM Policy Examples

1. IAM Policy that allows performing actions on EC2 and ELB from a specific region.

{

    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowEC2AndELBActionFromSpecificRegion",
            "Effect": "Allow",
            "Action": [
   "ec2:*",
   "elasticloadbalancing:*"
],   
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestedRegion": "ap-south-1"
                }
            }
        }
    ]