Build an inventory

The assessment reads an inventory: one JSON file that lists your resources. Make it with your provider's own command-line tool, read-only credentials and jq: run the commands below, then the program from the repository that turns their output into inventory.json. Every command lists, describes or queries, and none changes anything in your cloud. Each source also has a script that runs the same commands and the program for you.

The easy route: AWS CloudShell, Google Cloud Shell and Azure Cloud Shell (Bash) have the provider's CLI signed in and jq installed, so the commands and the scripts run there as they are.

The inventory guide (opens in a new tab) on GitHub is the full text these commands come from: the permissions each provider needs, what each command collects and how the programs classify it.

AWS

The shorter path: Download the script, or to read it first, View it (opens in a new tab) on GitHub; then run bash shift2eu-inventory-aws.sh. It runs exactly the commands below and the program, and writes the inventory into inventories/; --help prints its options. It runs with your cloud credentials, so read it before you run it, and check the file you downloaded is the release's: compare the digest shasum -a 256 shift2eu-inventory-aws.sh prints for it (sha256sum on Linux) with the script's SHA-256 in the attested bundle's manifest.json (Verify this site), or take the script from the release archive, which its attestation and checksums.txt cover.

Collect the output

Run these from the directory you want the files in: they write the provider's output into inventories/aws/. Run them in order, in one shell: the first sets the variables the others use.

export AWS_REGION=eu-central-1
out="inventories/aws/$AWS_REGION"
mkdir -p "$out"
aws ec2 describe-instances --output json --query '{Reservations: Reservations[].{Instances: Instances[].{
  InstanceId: InstanceId, InstanceType: InstanceType, State: {Name: State.Name},
  Placement: {AvailabilityZone: Placement.AvailabilityZone},
  BlockDeviceMappings: BlockDeviceMappings[].{Ebs: {VolumeId: Ebs.VolumeId}},
  NetworkInterfaces: NetworkInterfaces[].{Ipv6AddressCount: length(Ipv6Addresses || `[]`)},
  Tags: Tags[].{Key: Key}}}}' > "$out/ec2-instances.json"
aws opensearch list-domain-names --output json \
  --query '{DomainNames: DomainNames[].{DomainName: DomainName}}' > "$out/opensearch-domain-names.json"
jq -r '.DomainNames[].DomainName' "$out/opensearch-domain-names.json" |
  xargs -r -n 5 aws opensearch describe-domains --output json --query '{DomainStatusList: DomainStatusList[].{
    DomainName: DomainName, ARN: ARN, EngineVersion: EngineVersion, Deleted: Deleted,
    ClusterConfig: {InstanceType: ClusterConfig.InstanceType, InstanceCount: ClusterConfig.InstanceCount,
    ZoneAwarenessEnabled: ClusterConfig.ZoneAwarenessEnabled,
    MultiAZWithStandbyEnabled: ClusterConfig.MultiAZWithStandbyEnabled},
    EBSOptions: {EBSEnabled: EBSOptions.EBSEnabled, VolumeSize: EBSOptions.VolumeSize},
    EncryptionAtRestOptions: {Enabled: EncryptionAtRestOptions.Enabled}}}' --domain-names \
  > "$out/opensearch-domains.json"
f="$out/opensearchserverless-collections.json"
: > "$f"
token=
while :; do
  if ! page=$(aws opensearchserverless list-collections --output json --max-results 100 \
      ${token:+--next-token} ${token:+"$token"} \
      --query '{collectionSummaries: collectionSummaries[].{id: id, name: name}, nextToken: nextToken}'); then
    if [ -n "$token" ]; then
      echo "list-collections failed: $f is incomplete; collect $out again" >&2
    else
      echo "list-collections failed on its first page: $f is empty;" \
        "if the region runs OpenSearch Serverless, collect $out again" >&2
    fi
    break
  fi
  printf '%s\n' "$page" >> "$f"
  last=$token
  token=$(printf '%s' "$page" | jq -r '.nextToken // empty')
  if [ -z "$token" ]; then
    break
  fi
  if [ "$token" = "$last" ]; then
    echo "list-collections repeated its nextToken: $f may be incomplete; collect $out again" >&2
    break
  fi
done
jq -r '.collectionSummaries[]?.id' "$f" |
  xargs -r -n 100 aws opensearchserverless batch-get-collection --output json --query '{collectionDetails:
    collectionDetails[].{name: name, arn: arn, type: type, standbyReplicas: standbyReplicas,
    status: status}}' --ids \
  > "$out/opensearchserverless-batch-collections.json"
aws kafka list-clusters-v2 --output json --query '{ClusterInfoList: ClusterInfoList[].{
  ClusterName: ClusterName, ClusterType: ClusterType, ClusterArn: ClusterArn, State: State,
  Provisioned: Provisioned.{NumberOfBrokerNodes: NumberOfBrokerNodes,
  BrokerNodeGroupInfo: BrokerNodeGroupInfo.{InstanceType: InstanceType, ClientSubnets: ClientSubnets,
  StorageInfo: {EbsStorageInfo: {VolumeSize: StorageInfo.EbsStorageInfo.VolumeSize}}}}}}' \
  > "$out/kafka-clusters-v2.json"
# The vCPU and memory of the instance types in use.
# A search domain's and a Kafka broker's instance type is built on an EC2 type
# (r6g.large.search and kafka.m5.large are r6g.large and m5.large), asked for one
# at a time: a type with no EC2 twin fails alone and its resource stays unsized.
{ jq -r '[.Reservations[].Instances[].InstanceType] | unique[]' "$out/ec2-instances.json" |
    xargs -r -n 100 aws ec2 describe-instance-types --output json --query '{InstanceTypes: InstanceTypes[].{
      InstanceType: InstanceType, VCpuInfo: {DefaultVCpus: VCpuInfo.DefaultVCpus},
      MemoryInfo: {SizeInMiB: MemoryInfo.SizeInMiB}}}' --instance-types
  jq -rn '[inputs | (.DomainStatusList[]?.ClusterConfig.InstanceType // empty | select(endswith(".search"))
      | sub("\\.search$"; "")), (.ClusterInfoList[]?.Provisioned.BrokerNodeGroupInfo.InstanceType // empty
      | select(startswith("kafka.")) | sub("^kafka\\."; ""))] | unique[] | select(test("^o[a-z][0-9]") | not)' \
    "$out/opensearch-domains.json" "$out/kafka-clusters-v2.json" |
    xargs -r -n 1 aws ec2 describe-instance-types --output json --query '{InstanceTypes: InstanceTypes[].{
      InstanceType: InstanceType, VCpuInfo: {DefaultVCpus: VCpuInfo.DefaultVCpus},
      MemoryInfo: {SizeInMiB: MemoryInfo.SizeInMiB}}}' --instance-types
} > "$out/ec2-instance-types.json"
aws ec2 describe-volumes --output json --query '{Volumes: Volumes[].{
  VolumeId: VolumeId, AvailabilityZone: AvailabilityZone, Encrypted: Encrypted, Size: Size,
  Attachments: Attachments[].{InstanceId: InstanceId, DeleteOnTermination: DeleteOnTermination}}}' \
  > "$out/ec2-volumes.json"
aws ec2 describe-snapshots --owner-ids self --output json \
  --query '{Snapshots: Snapshots[].{VolumeId: VolumeId}}' > "$out/ec2-snapshots.json"
aws autoscaling describe-auto-scaling-groups --output json --query '{AutoScalingGroups: AutoScalingGroups[].{
  AutoScalingGroupName: AutoScalingGroupName, AutoScalingGroupARN: AutoScalingGroupARN,
  MinSize: MinSize, MaxSize: MaxSize, AvailabilityZones: AvailabilityZones,
  Tags: Tags[].{Key: Key}}}' > "$out/autoscaling-groups.json"
aws s3api list-buckets --output json \
  --query '{Buckets: Buckets[].{Name: Name, BucketRegion: BucketRegion}}' > "$out/s3-buckets.json"
jq -r '.Buckets[].Name' "$out/s3-buckets.json" | while read -r bucket; do
  aws s3api get-bucket-versioning --bucket "$bucket" --output json --query '{Status: Status}' |
    jq --arg bucket "$bucket" '{Bucket: $bucket, Versioning: .}'
done > "$out/s3-versioning.json"
aws rds describe-db-instances --output json --query '{DBInstances: DBInstances[].{
  DBInstanceIdentifier: DBInstanceIdentifier, DBInstanceArn: DBInstanceArn,
  DBClusterIdentifier: DBClusterIdentifier, Engine: Engine, AllocatedStorage: AllocatedStorage,
  AvailabilityZone: AvailabilityZone, BackupRetentionPeriod: BackupRetentionPeriod, MultiAZ: MultiAZ,
  StorageEncrypted: StorageEncrypted,
  ReadReplicaDBInstanceIdentifiers: ReadReplicaDBInstanceIdentifiers}}' > "$out/rds-instances.json"
aws elasticache describe-replication-groups --output json --query '{ReplicationGroups: ReplicationGroups[].{
  ReplicationGroupId: ReplicationGroupId, ARN: ARN, Engine: Engine, AutomaticFailover: AutomaticFailover,
  MultiAZ: MultiAZ, ClusterEnabled: ClusterEnabled, SnapshotRetentionLimit: SnapshotRetentionLimit,
  AtRestEncryptionEnabled: AtRestEncryptionEnabled, StorageEncryptionType: StorageEncryptionType,
  MemberClusters: MemberClusters, NodeGroups: NodeGroups[].{
  NodeGroupMembers: NodeGroupMembers[].{CacheClusterId: CacheClusterId}},
  CacheNodeType: CacheNodeType}}' > "$out/elasticache-replication-groups.json"
aws elasticache describe-cache-clusters --output json --query '{CacheClusters: CacheClusters[].{
  CacheClusterId: CacheClusterId, ARN: ARN, ReplicationGroupId: ReplicationGroupId, Engine: Engine,
  NumCacheNodes: NumCacheNodes, SnapshotRetentionLimit: SnapshotRetentionLimit,
  AtRestEncryptionEnabled: AtRestEncryptionEnabled,
  CacheNodeType: CacheNodeType}}' > "$out/elasticache-cache-clusters.json"
aws elasticache describe-serverless-caches --output json --query '{ServerlessCaches: ServerlessCaches[].{
  ServerlessCacheName: ServerlessCacheName, ARN: ARN, Engine: Engine,
  SnapshotRetentionLimit: SnapshotRetentionLimit}}' \
  > "$out/elasticache-serverless-caches.json"
aws elbv2 describe-load-balancers --output json --query '{LoadBalancers: LoadBalancers[].{
  LoadBalancerName: LoadBalancerName, LoadBalancerArn: LoadBalancerArn, Type: Type,
  IpAddressType: IpAddressType, AvailabilityZones: AvailabilityZones[].{ZoneName: ZoneName}}}' \
  > "$out/elbv2-load-balancers.json"
jq -r '.LoadBalancers[].LoadBalancerArn' "$out/elbv2-load-balancers.json" | while read -r lb; do
  aws elbv2 describe-listeners --load-balancer-arn "$lb" --output json --query '{Listeners: Listeners[].{
    ListenerArn: ListenerArn, LoadBalancerArn: LoadBalancerArn, Protocol: Protocol, Port: Port}}'
done > "$out/elbv2-listeners.json"
aws elbv2 describe-target-groups --output json --query '{TargetGroups: TargetGroups[].{
  TargetGroupArn: TargetGroupArn, IpAddressType: IpAddressType, LoadBalancerArns: LoadBalancerArns}}' \
  > "$out/elbv2-target-groups.json"
# The tag keys of the load balancers, to leave out those a Kubernetes cluster created.
jq -r '.LoadBalancers[].LoadBalancerArn' "$out/elbv2-load-balancers.json" |
  xargs -r -n 20 aws elbv2 describe-tags --output json --query '{TagDescriptions: TagDescriptions[].{
    ResourceArn: ResourceArn, Tags: Tags[].{Key: Key}}}' --resource-arns > "$out/elbv2-tags.json"
aws elb describe-load-balancers --output json --query '{LoadBalancerDescriptions: LoadBalancerDescriptions[].{
  LoadBalancerName: LoadBalancerName, AvailabilityZones: AvailabilityZones}}' \
  > "$out/elb-load-balancers.json"
aws efs describe-file-systems --output json --query '{FileSystems: FileSystems[].{
  FileSystemId: FileSystemId, FileSystemArn: FileSystemArn, Encrypted: Encrypted,
  AvailabilityZoneName: AvailabilityZoneName, SizeInBytes: {Value: SizeInBytes.Value}}}' \
  > "$out/efs-file-systems.json"
aws eks list-clusters --output json | jq -r '.clusters[]' | while read -r cluster; do
  aws eks describe-cluster --name "$cluster" --output json \
    --query '{cluster: {name: cluster.name, arn: cluster.arn}}'
  aws eks list-nodegroups --cluster-name "$cluster" --output json | jq -r '.nodegroups[]' |
    while read -r nodegroup; do
      aws eks describe-nodegroup --cluster-name "$cluster" --nodegroup-name "$nodegroup" \
        --output json --query '{nodegroup: {clusterName: nodegroup.clusterName,
          nodegroupArn: nodegroup.nodegroupArn, scalingConfig: nodegroup.scalingConfig,
          resources: {autoScalingGroups: nodegroup.resources.autoScalingGroups}}}'
    done
done > "$out/eks.json"
aws lambda list-functions --output json \
  --query '{Functions: Functions[].{FunctionName: FunctionName, FunctionArn: FunctionArn}}' \
  > "$out/lambda-functions.json"
aws sqs list-queues --output json | jq -r '.QueueUrls[]?' | while read -r queue; do
  aws sqs get-queue-attributes --queue-url "$queue" --output json \
    --attribute-names QueueArn RedrivePolicy SqsManagedSseEnabled KmsMasterKeyId
done > "$out/sqs-queues.json"
aws sns list-topics --output json | jq -r '.Topics[]?.TopicArn' | while read -r topic; do
  aws sns get-topic-attributes --topic-arn "$topic" --output json --query '{Attributes: {
    TopicArn: Attributes.TopicArn, KmsMasterKeyId: Attributes.KmsMasterKeyId}}'
done > "$out/sns-topics.json"
# Route 53 hosted zones: each zone's ID, name and whether it is private.
aws route53 list-hosted-zones --output json \
  --query 'HostedZones[].{Id: Id, Name: Name, PrivateZone: Config.PrivateZone}' \
  > "$out/route53-hosted-zones.json"
# Whether each public zone is signed with DNSSEC: its signed state alone, never its keys.
# The zone's ID is passed without the /hostedzone/ prefix the list writes.
jq -r '.[] | select(.PrivateZone == false) | .Id | ltrimstr("/hostedzone/")' \
    "$out/route53-hosted-zones.json" |
  while IFS= read -r id; do
    aws route53 get-dnssec --hosted-zone-id "$id" --output json --query 'Status.ServeSignature' |
      jq --arg hz "$id" '{Id: ("/hostedzone/" + $hz), ServeSignature: .}'
  done | jq -s . > "$out/route53-dnssec.json"
# Optional, for dns-routing only (needs route53:ListResourceRecordSets, see "AWS permissions"):
# how many record sets of each public zone route by client or by health, a count and no record.
jq -r '.[] | select(.PrivateZone == false) | .Id | ltrimstr("/hostedzone/")' \
    "$out/route53-hosted-zones.json" |
  while IFS= read -r id; do
    aws route53 list-resource-record-sets --hosted-zone-id "$id" --output json \
      --query 'length(ResourceRecordSets[?SetIdentifier || HealthCheckId || MultiValueAnswer || TrafficPolicyInstanceId])' |
      jq --arg hz "$id" '{Id: ("/hostedzone/" + $hz), RoutedRecordSets: .}'
  done | jq -s . > "$out/route53-routed-record-sets.json"
# Optional: everything else, from AWS Config (see "Everything else on AWS").
aws configservice select-resource-config \
  --expression "SELECT resourceId, resourceName, resourceType, awsRegion" \
  --output json > "$out/config.json"

Build the inventory

This runs the program docs/guide/inventory/aws.jq from a clone of the repository: run it in the clone, in the directory that holds inventories/aws/, or give -f the path of your copy of the program linked below.

jq -n -f docs/guide/inventory/aws.jq inventories/aws/*/*.json > inventories/aws.inventory.json

The program is docs/guide/inventory/aws.jq (opens in a new tab). Run the collect commands once per region you use. Review the inventory the program writes, then delete the collected directory: it holds the provider's raw output.

GCP

The shorter path: Download the script, or to read it first, View it (opens in a new tab) on GitHub; then run bash shift2eu-inventory-gcp.sh. It runs exactly the commands below and the program, and writes the inventory into inventories/; --help prints its options. It runs with your cloud credentials, so read it before you run it, and check the file you downloaded is the release's: compare the digest shasum -a 256 shift2eu-inventory-gcp.sh prints for it (sha256sum on Linux) with the script's SHA-256 in the attested bundle's manifest.json (Verify this site), or take the script from the release archive, which its attestation and checksums.txt cover.

Collect the output

Run these from the directory you want the files in: they write the provider's output into inventories/gcp/. Run them in order, in one shell: the first sets the variables the others use.

project=example-project   # your project ID
out=inventories/gcp
mkdir -p "$out"
# Keep only the one label gcp.jq reads, not the values of any other label.
gcloud asset search-all-resources --scope="projects/$project" --quiet \
  --format='json(name,assetType,location,labels)' |
  jq '[.[] | if .labels then .labels |= with_entries(select(.key == "goog-gke-node")) else . end]' \
  > "$out/assets.json"
# Whether the asset listing holds an asset type, in a region when one is given:
# the Memorystore, Filestore and Artifact Registry lists below run only then.
has() { jq -e --arg t "$1" --arg r "${2:-}" \
  'any(.[]; .assetType == $t and ($r == "" or (.name | contains("/locations/" + $r + "/"))))' \
  "$out/assets.json" > /dev/null; }
gcloud compute instances list --project="$project" --quiet \
  --format='json(kind,selfLink,machineType,metadata.items[].key,disks[].source,disks[].boot,disks[].autoDelete,networkInterfaces[].stackType,networkInterfaces[].ipv6AccessConfigs[].type)' \
  > "$out/compute-instances.json"
# The vCPU and memory of the machine types in use, and every disk's size.
types="$(jq -r '[.[].machineType // empty | split("/") | last] | unique | join(" ")' "$out/compute-instances.json")"
# With no instances there are no types to ask for: write an empty list instead.
if [ -n "$types" ]; then
  gcloud compute machine-types list --project="$project" --filter="name:($types)" --quiet \
    --format='json(kind,selfLink,name,zone,guestCpus,memoryMb)' > "$out/compute-machine-types.json"
else
  echo '[]' > "$out/compute-machine-types.json"
fi
gcloud compute disks list --project="$project" --quiet \
  --format='json(kind,name,zone,region,sizeGb)' > "$out/compute-disks.json"
gcloud compute instance-groups managed list --project="$project" --quiet \
  --format='json(kind,selfLink,status.autoscaler)' > "$out/compute-instance-groups.json"
gcloud compute snapshots list --project="$project" --quiet \
  --format='json(kind,sourceDisk)' > "$out/compute-snapshots.json"
gcloud sql instances list --project="$project" --quiet \
  --format='json(kind,selfLink,region,databaseVersion,replicaNames,settings.availabilityType,settings.tier,settings.dataDiskSizeGb,settings.backupConfiguration.pointInTimeRecoveryEnabled,settings.backupConfiguration.binaryLogEnabled)' \
  > "$out/sql-instances.json"
gcloud storage buckets list --project="$project" --raw --quiet \
  --format='json(kind,name,versioning)' > "$out/storage-buckets.json"
gcloud container clusters list --project="$project" --quiet \
  --format='json(selfLink,location,currentNodeCount,autopilot.enabled,nodePools[].autoscaling.enabled,nodePools[].instanceGroupUrls)' \
  > "$out/container-clusters.json"
gcloud pubsub subscriptions list --project="$project" --quiet \
  --format='json(name,deadLetterPolicy.deadLetterTopic)' > "$out/pubsub-subscriptions.json"
# Load balancers: global and every region's, each list by default.
gcloud compute url-maps list --project="$project" --quiet \
  --format='json(selfLink,region,defaultService,defaultRouteAction.weightedBackendServices[].backendService,defaultRouteAction.requestMirrorPolicy.backendService,defaultCustomErrorResponsePolicy.errorService,pathMatchers[].defaultService,pathMatchers[].defaultRouteAction.weightedBackendServices[].backendService,pathMatchers[].defaultRouteAction.requestMirrorPolicy.backendService,pathMatchers[].defaultCustomErrorResponsePolicy.errorService,pathMatchers[].pathRules[].service,pathMatchers[].pathRules[].routeAction.weightedBackendServices[].backendService,pathMatchers[].pathRules[].routeAction.requestMirrorPolicy.backendService,pathMatchers[].pathRules[].customErrorResponsePolicy.errorService,pathMatchers[].routeRules[].service,pathMatchers[].routeRules[].routeAction.weightedBackendServices[].backendService,pathMatchers[].routeRules[].routeAction.requestMirrorPolicy.backendService,pathMatchers[].routeRules[].customErrorResponsePolicy.errorService)' \
  > "$out/compute-url-maps.json"
gcloud compute backend-services list --project="$project" --quiet \
  --format='json(kind,selfLink,region,protocol,loadBalancingScheme,ipAddressSelectionPolicy)' \
  > "$out/compute-backend-services.json"
gcloud compute forwarding-rules list --project="$project" --quiet \
  --format='json(kind,selfLink,region,IPProtocol,ipVersion,target,backendService)' \
  > "$out/compute-forwarding-rules.json"
gcloud compute target-pools list --project="$project" --quiet \
  --format='json(kind,selfLink,region)' > "$out/compute-target-pools.json"
gcloud compute target-https-proxies list --project="$project" --quiet \
  --format='json(kind,selfLink,urlMap)' > "$out/compute-target-https-proxies.json"
gcloud compute target-http-proxies list --project="$project" --quiet \
  --format='json(kind,selfLink,urlMap)' > "$out/compute-target-http-proxies.json"
# Cloud DNS managed zones: each zone's number, name, visibility and whether it is
# signed. The list writes no project, so jq adds it, for the join with the asset
# listing, which names a zone by its number.
gcloud dns managed-zones list --project="$project" --quiet \
  --format='json(kind,id,name,visibility,dnssecConfig.state)' |
  jq --arg p "$project" '[.[] | .project = $p]' > "$out/dns-managed-zones.json"
# Optional, for dns-routing only (needs dns.resourceRecordSets.list, see "GCP permissions"):
# how many record sets of each public zone route by a policy, a count and no record.
jq -r '.[] | select(.visibility == "public") | "\(.id) \(.name)"' "$out/dns-managed-zones.json" |
  while read -r id zone; do
    if routed_types=$(gcloud dns record-sets list --project="$project" --zone="$zone" --quiet \
        --filter='routingPolicy:*' --format='value(type)'); then
      printf '%s' "$routed_types" | jq -R -s --arg p "$project" --arg i "$id" \
        '{project: $p, id: $i, routedRecordSets: (split("\n") | map(select(. != "")) | length)}'
    fi
  done | jq -s . > "$out/dns-routed-record-sets.json"
# Memorystore, per region: the regions come from the asset listing, and each
# list runs only in a region that holds its asset type.
for region in $(jq -r '[.[] | select(.assetType | test("^(redis|memorystore)\\.googleapis\\.com/")) | .name | capture("/locations/(?<r>[^/]+)/").r] | unique | .[]' "$out/assets.json"); do
  if has redis.googleapis.com/Instance "$region"; then
    gcloud redis instances list --project="$project" --region="$region" --quiet \
      --format='json(name,tier,memorySizeGb,replicaCount,locationId,alternativeLocationId,nodes[].zone,persistenceConfig.persistenceMode)'
  fi
  if has redis.googleapis.com/Cluster "$region"; then
    gcloud redis clusters list --project="$project" --region="$region" --quiet \
      --format='json(name,shardCount,replicaCount,nodeType,sizeGb,zoneDistributionConfig.mode,persistenceConfig.mode)'
  fi
  if has memorystore.googleapis.com/Instance "$region"; then
    gcloud memorystore instances list --project="$project" --location="$region" --quiet \
      --format='json(name,mode,shardCount,replicaCount,nodeType,nodeConfig.sizeGb,zoneDistributionConfig.mode,persistenceConfig.mode)'
  fi
done > "$out/memorystore.json"
# Filestore and Artifact Registry, when the asset listing holds one of theirs.
if has file.googleapis.com/Instance; then
  gcloud filestore instances list --project="$project" --quiet \
    --format='json(name,tier,fileShares[].capacityGb,protocol)' > "$out/filestore-instances.json"
else
  echo '[]' > "$out/filestore-instances.json"
fi
if has artifactregistry.googleapis.com/Repository; then
  gcloud artifacts repositories list --project="$project" --location=all --quiet \
    --format='json(name,format,mode)' > "$out/artifacts-repositories.json"
else
  echo '[]' > "$out/artifacts-repositories.json"
fi
# Managed Service for Apache Kafka, per region the asset listing names a cluster in,
# merged into one list (an empty one when there is none): only each cluster's name
# and capacity, never its bootstrap address or network access.
for region in $(jq -r '[.[] | select(.assetType == "managedkafka.googleapis.com/Cluster") | .name | capture("/locations/(?<r>[^/]+)/").r] | unique | .[]' "$out/assets.json"); do
  gcloud managed-kafka clusters list --project="$project" --location="$region" --quiet \
    --format='json(name,capacityConfig)'
done | jq -s 'add // []' > "$out/managed-kafka-clusters.json"
# The Cloud Run service each 2nd gen function runs on, per region with functions.
for region in $(jq -r '[.[] | select(.assetType == "cloudfunctions.googleapis.com/Function") | .name | capture("/locations/(?<r>[^/]+)/").r] | unique | .[]' "$out/assets.json"); do
  gcloud functions list --project="$project" --v2 --regions="$region" --quiet \
    --format='json(name,serviceConfig.service)'
done > "$out/functions.json"

Build the inventory

This runs the program docs/guide/inventory/gcp.jq from a clone of the repository: run it in the clone, in the directory that holds inventories/gcp/, or give -f the path of your copy of the program linked below.

jq -n -f docs/guide/inventory/gcp.jq inventories/gcp/*.json > inventories/gcp.inventory.json

The program is docs/guide/inventory/gcp.jq (opens in a new tab). Review the inventory the program writes, then delete the collected directory: it holds the provider's raw output.

Azure

The shorter path: Download the script, or to read it first, View it (opens in a new tab) on GitHub; then run bash shift2eu-inventory-azure.sh. It runs exactly the commands below and the program, and writes the inventory into inventories/; --help prints its options. It runs with your cloud credentials, so read it before you run it, and check the file you downloaded is the release's: compare the digest shasum -a 256 shift2eu-inventory-azure.sh prints for it (sha256sum on Linux) with the script's SHA-256 in the attested bundle's manifest.json (Verify this site), or take the script from the release archive, which its attestation and checksums.txt cover.

Collect the output

Run these from the directory you want the files in: they write the provider's output into inventories/azure/. Run them in order, in one shell: the first sets the variables the others use.

subscription="$(az account show --query id --output tsv)"
out=inventories/azure
mkdir -p "$out"
# Keep only the properties azure.jq reads, and only for the types it reads them from.
# An HDInsight cluster has a branch of its own: its roles array is expanded and
# only its kind, its state and the worker role's count, VM size and disks are
# packed back, as each role
# also carries its admin user, SSH key, script actions and network.
query="Resources
| where type =~ 'microsoft.hdinsight/clusters'
| mv-expand role = properties.computeProfile.roles
| where role.name =~ 'workernode'
| extend properties = bag_pack(
    'clusterDefinition', bag_pack('kind', properties.clusterDefinition.kind),
    'clusterState', properties.clusterState,
    'computeProfile', bag_pack('roles', pack_array(bag_pack(
      'name', role.name,
      'targetInstanceCount', role.targetInstanceCount,
      'hardwareProfile', bag_pack('vmSize', role.hardwareProfile.vmSize),
      'dataDisksGroups', pack_array(bag_pack(
        'disksPerNode', role.dataDisksGroups[0].disksPerNode,
        'diskSizeGB', role.dataDisksGroups[0].diskSizeGB))))))
| union (Resources
  | where type !~ 'microsoft.hdinsight/clusters'
  | extend properties = case(
    type =~ 'microsoft.compute/virtualmachines', bag_pack(
      'virtualMachineScaleSet', bag_pack('id', properties.virtualMachineScaleSet.id),
      'storageProfile', bag_pack(
        'osDisk', bag_pack('managedDisk', bag_pack('id', properties.storageProfile.osDisk.managedDisk.id)),
        'dataDisks', properties.storageProfile.dataDisks),
      'networkProfile', bag_pack('networkInterfaces', properties.networkProfile.networkInterfaces),
      'hardwareProfile', bag_pack('vmSize', properties.hardwareProfile.vmSize)),
    type =~ 'microsoft.compute/disks',
      bag_pack('diskSizeGB', properties.diskSizeGB),
    type =~ 'microsoft.network/networkinterfaces',
      bag_pack('ipConfigurations', properties.ipConfigurations),
    type =~ 'microsoft.compute/snapshots',
      bag_pack('creationData', bag_pack('sourceResourceId', properties.creationData.sourceResourceId)),
    type =~ 'microsoft.insights/autoscalesettings',
      bag_pack('enabled', properties.enabled, 'targetResourceUri', properties.targetResourceUri),
    type in~ ('microsoft.dbforpostgresql/flexibleservers', 'microsoft.dbformysql/flexibleservers'),
      bag_pack('backup', bag_pack('backupRetentionDays', properties.backup.backupRetentionDays),
        'highAvailability', bag_pack('mode', properties.highAvailability.mode),
        'sourceServerResourceId', properties.sourceServerResourceId,
        'storage', bag_pack('storageSizeGB', properties.storage.storageSizeGB)),
    type =~ 'microsoft.containerservice/managedclusters',
      bag_pack('nodeResourceGroup', properties.nodeResourceGroup,
        'agentPoolProfiles', properties.agentPoolProfiles),
    type =~ 'microsoft.compute/virtualmachinescalesets',
      bag_pack('virtualMachineProfile', bag_pack('networkProfile',
        bag_pack('networkInterfaceConfigurations',
          properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations))),
    type =~ 'microsoft.cache/redis',
      bag_pack('sku', properties.sku,
        'shardCount', properties.shardCount,
        'replicasPerMaster', properties.replicasPerMaster,
        'replicasPerPrimary', properties.replicasPerPrimary,
        'zonalAllocationPolicy', properties.zonalAllocationPolicy,
        'redisConfiguration', bag_pack('rdb-backup-enabled', properties.redisConfiguration['rdb-backup-enabled'])),
    type =~ 'microsoft.cache/redisenterprise',
      bag_pack('highAvailability', properties.highAvailability,
        'redundancyMode', properties.redundancyMode),
    type =~ 'microsoft.documentdb/databaseaccounts',
      bag_pack('backupPolicy', bag_pack('type', properties.backupPolicy.type),
        'locations', properties.locations),
    type =~ 'microsoft.documentdb/mongoclusters',
      bag_pack('highAvailability', bag_pack('targetMode', properties.highAvailability.targetMode),
        'sharding', bag_pack('shardCount', properties.sharding.shardCount),
        'storage', bag_pack('sizeGb', properties.storage.sizeGb),
        'compute', bag_pack('tier', properties.compute.tier),
        'replicaParameters', bag_pack('sourceResourceId', properties.replicaParameters.sourceResourceId)),
    type =~ 'microsoft.network/loadbalancers',
      bag_pack('frontendIPConfigurations', properties.frontendIPConfigurations,
        'backendAddressPools', properties.backendAddressPools,
        'loadBalancingRules', properties.loadBalancingRules),
    type =~ 'microsoft.network/publicipaddresses',
      bag_pack('publicIPAddressVersion', properties.publicIPAddressVersion),
    type =~ 'microsoft.fileshares/fileshares',
      bag_pack('protocol', properties.protocol,
        'provisionedStorageGiB', properties.provisionedStorageGiB,
        'redundancy', properties.redundancy),
    type =~ 'microsoft.network/dnszones',
      bag_pack('zoneType', properties.zoneType),
    dynamic(null)))
| project id, name, type, kind, location, zones, sku, properties"
page=1
token=""
while :; do
  if [ -z "$token" ]; then
    az graph query --graph-query "$query" --subscriptions "$subscription" --first 1000 \
      --output json > "$out/graph-$page.json"
  else
    az graph query --graph-query "$query" --subscriptions "$subscription" --first 1000 \
      --skip-token "$token" --output json > "$out/graph-$page.json"
  fi
  token="$(jq -r '.skip_token // empty' "$out/graph-$page.json")"
  [ -n "$token" ] || break
  page=$((page + 1))
done
az servicebus namespace list --subscription "$subscription" \
  --query "[].[name, resourceGroup]" --output tsv |
  while read -r name group; do
    az servicebus queue list --subscription "$subscription" --namespace-name "$name" \
      --resource-group "$group" --query "[].{id: id, name: name, type: type}" --output json
    az servicebus topic list --subscription "$subscription" --namespace-name "$name" \
      --resource-group "$group" --query "[].{id: id, name: name, type: type}" --output json
    az servicebus topic list --subscription "$subscription" --namespace-name "$name" \
      --resource-group "$group" --query "[].name" --output tsv |
      while read -r topic; do
        az servicebus topic subscription list --subscription "$subscription" \
          --namespace-name "$name" --resource-group "$group" --topic-name "$topic" \
          --query "[].{id: id, name: name, type: type}" --output json
      done
  done > "$out/servicebus.json"
az storage account list --subscription "$subscription" \
  --query "[?kind=='StorageV2' || kind=='Storage'].id" --output tsv |
  while read -r id; do
    case "$id" in
      *[?#@%\\[:space:][:cntrl:]]*) echo "skipped an id that is no resource ID" >&2; continue ;;
      /subscriptions/*) ;;
      *) echo "skipped an id that is no resource ID" >&2; continue ;;
    esac
    az rest --method get \
      --url "https://management.azure.com${id}/queueServices/default/queues?api-version=2023-05-01" \
      --query "value[].{id: id, name: name, type: type}" --output json
  done > "$out/storage-queues.json"
az storage account list --subscription "$subscription" \
  --query "[].[name, resourceGroup]" --output tsv |
  while read -r name group; do
    az storage account blob-service-properties show --subscription "$subscription" \
      --account-name "$name" --resource-group "$group" \
      --query "{id: id, type: type, isVersioningEnabled: isVersioningEnabled}" --output json
  done > "$out/blob-services.json"
# The file shares of FileStorage accounts, the only ones with NFS shares, and their snapshots.
az storage account list --subscription "$subscription" \
  --query "[?kind=='FileStorage'].id" --output tsv |
  while read -r id; do
    case "$id" in
      *[?#@%\\[:space:][:cntrl:]]*) echo "skipped an id that is no resource ID" >&2; continue ;;
      /subscriptions/*) ;;
      *) echo "skipped an id that is no resource ID" >&2; continue ;;
    esac
    az rest --method get \
      --url "https://management.azure.com${id}/fileServices/default/shares?api-version=2023-05-01&\$expand=snapshots" \
      --query "value[].{id: id, name: name, type: type, properties: {enabledProtocols: properties.enabledProtocols, shareQuota: properties.shareQuota, snapshotTime: properties.snapshotTime}}" \
      --output json
  done > "$out/file-shares.json"
# The databases of every Azure Managed Redis (Redis Enterprise) cluster: clustering and persistence.
jq -r '.data[] | select(.type == "microsoft.cache/redisenterprise") | .id' "$out"/graph-*.json |
  while read -r id; do
    case "$id" in
      *[?#@%\\[:space:][:cntrl:]]*) echo "skipped an id that is no resource ID" >&2; continue ;;
      /subscriptions/*) ;;
      *) echo "skipped an id that is no resource ID" >&2; continue ;;
    esac
    az rest --method get --url "https://management.azure.com${id}/databases?api-version=2026-09-01" \
      --query "value[].{id: id, name: name, type: type, properties: {clusteringPolicy: properties.clusteringPolicy, persistence: properties.persistence}}" \
      --output json
  done > "$out/redis-databases.json"
# The vCPU and memory of every VM size, in each region with virtual machines, scale sets
# or HDInsight clusters.
jq -r '[.data[] | select(.type == "microsoft.compute/virtualmachines"
    or .type == "microsoft.compute/virtualmachinescalesets"
    or .type == "microsoft.hdinsight/clusters") | .location] | unique[]' "$out"/graph-*.json |
  while read -r location; do
    az vm list-sizes --subscription "$subscription" --location "$location" --output json
  done > "$out/vm-sizes.json"
# Whether each public DNS zone is signed with DNSSEC: its provisioning state alone, never its keys.
# An unsigned zone answers "(NotFound) DNSSEC is not enabled for DNS zone ...": that error is expected,
# as is the warning that the dnssec-config command group is experimental.
jq -r '.data[] | select(.type == "microsoft.network/dnszones"
    and ((.properties.zoneType // "Public") | ascii_downcase) != "private")
  | [(.id | split("/")[4]), .name] | @tsv' "$out"/graph-*.json |
  while read -r rg zone; do
    az network dns dnssec-config show --subscription "$subscription" \
      --resource-group="$rg" --zone-name="$zone" \
      --query "{id: id, type: type, provisioningState: provisioningState || properties.provisioningState}" \
      --output json || :
  done > "$out/dns-dnssec.json"

Build the inventory

This runs the program docs/guide/inventory/azure.jq from a clone of the repository: run it in the clone, in the directory that holds inventories/azure/, or give -f the path of your copy of the program linked below.

jq -n -f docs/guide/inventory/azure.jq inventories/azure/*.json > inventories/azure.inventory.json

The program is docs/guide/inventory/azure.jq (opens in a new tab). Review the inventory the program writes, then delete the collected directory: it holds the provider's raw output.

Planning a migration?

Questions about your results, or how to move forward?

We're happy to help you read an assessment, weigh the EU options, or plan the move itself. Email info@shift2eu.com.

Email info@shift2eu.com