Utilisation avancée de AWS CLI pour 3DS OUTSCALE
Grâce aux différents alias AWS CLI, vous pouvez aisément manipuler vos ressources OUTSCALE. Voici quelques exemples pour débuter :
Vous devez créer le fichier suivant : ~/.aws/cli/alias |
[toplevel]
# Lister toutes vos instances en fonctionnement
ls-vm=ec2 describe-instances \
--filter Name=instance-state-name,Values=running \
--query 'Reservations[].Instances[].{ID: InstanceId, VPC: VpcId, "Private IP": PrivateIpAddress, "Public IP": PublicIpAddress,Key: KeyName,Name: Tags[?Key==`Name`].Value | [0],"Security Group": SecurityGroups[0].GroupId ,Type: InstanceType, Volumes: BlockDeviceMappings[0].Ebs.VolumeId}' \
--output table
# Lister tous vos volumes
ls-volumes=ec2 describe-volumes \
--query 'Volumes[].{VolumeId: VolumeId,State: State,Size: Size,Name: Tags[0].Value,AZ: AvailabilityZone}' \
--output table
# Lister tous vos snapshots
ls-snapshots=ec2 describe-snapshots \
--query 'Snapshots[].{SnapshotId: SnapshotId,Description: Description, VolumeId: VolumeId,Size: VolumeSize,Name: Tags[0].Value}' \
--output table
# Lister tous vos security groups ouverts sur la plage de ports 0.0.0.0/0
ls-open-ports=ec2 describe-security-groups \
--filters Name=ip-permission.cidr,Values=0.0.0.0/0 \
--query 'SecurityGroups[].{
GroupName:GroupName,
GroupId:GroupId,
PortRanges:
IpPermissions[?contains(IpRanges[].CidrIp, `0.0.0.0/0`)].[
join(`:`, [IpProtocol, join(`-`, [to_string(FromPort), to_string(ToPort)])])
][]
}' \
--output text
$ aws ls-vm --region eu-west-2
--------------------------------------------------------------------------------------------------------------------------------------------
| DescribeInstances |
+------------+-------------------+----------+-----------+-------------+-----------------+-----------------+---------------+----------------+
| ID | Key | Name | Platform | Private IP | Public IP | Security Group | Type | VPC |
+------------+-------------------+----------+-----------+-------------+-----------------+-----------------+---------------+----------------+
| i-5f070bbd| user-eu-west-2 | Fedora | Linux | 10.8.13.28 | 171.33.95.101 | sg-20cc20e7 | t2.medium | None |
| i-1e80fc41| Bees | None | Linux | 10.0.3.144 | None | sg-175cc268 | tinav4.c4r2 | vpc-d6f90876 |
| i-2a43891f| Bees | None | Linux | 10.0.3.181 | None | sg-175cc268 | tinav4.c4r2 | vpc-d6f90876 |
| i-052a86ef| Bees | Bouncer | Linux | 10.0.1.21 | 171.33.120.213 | sg-f9cd8117 | c4.large | vpc-d6f90876 |
+------------+-------------------+----------+-----------+-------------+-----------------+-----------------+---------------+----------------+
Si vous souhaitez exploiter le Cloud OUTSCALE avec AWS CLI sans devoir spécifier à chaque fois les différents endpoints, procédez comme suit :
Assurez-vous de mettre à jour les endpoints à chaque nouvelle sortie d’une Région ou d’un service par 3DS OUTSCALE. Pour en savoir plus, voir À propos des Régions et Sous-régions. |
{
"partitions": [
{
"defaults": {
"hostname": "{service}.{region}.{dnsSuffix}",
"protocols": [
"https"
],
"signatureVersions": [
"v4"
]
},
"dnsSuffix": "outscale.com",
"partition": "osc",
"partitionName": "Outscale",
"regionRegex": "^(cloudgouv|us|eu|ap)\\-\\w+\\-\\d+$",
"regions": {
"eu-west-2": {
"description": "EU (Paris)"
},
"cloudgouv-eu-west-1": {
"description": "CloudGouv EU (Paris)"
},
"us-east-2": {
"description": "US East (NY)"
},
"us-west-1": {
"description": "US West (California)"
},
"ap-northeast-1": {
"description": "Japan (Tokyo)"
}
},
"services": {
"ec2": {
"endpoints": {
"eu-west-2": {"hostname": "fcu.eu-west-2.outscale.com"},
"cloudgouv-eu-west-1": {"hostname": "fcu.cloudgouv-eu-west-1.outscale.com"},
"us-east-2": {"hostname": "fcu.us-east-2.outscale.com"},
"us-west-1": {"hostname": "fcu.us-west-1.outscale.com"},
"ap-northeast-1": {"hostname": "fcu.ap-northeast-1.outscale.com"}
}
},
"elasticloadbalancing": {
"endpoints": {
"eu-west-2": {"hostname": "lbu.eu-west-2.outscale.com"},
"cloudgouv-eu-west-1": {"hostname": "lbu.cloudgouv-eu-west-1.outscale.com"},
"us-east-2": {"hostname": "lbu.us-east-2.outscale.com"},
"us-west-1": {"hostname": "lbu.us-west-1.outscale.com"},
"ap-northeast-1": {"hostname": "lbu.ap-northeast-1.outscale.com"}
}
},
"iam": {
"endpoints": {
"eu-west-2": {"hostname": "eim.eu-west-2.outscale.com"},
"cloudgouv-eu-west-1": {"hostname": "eim.cloudgouv-eu-west-1.outscale.com"},
"us-east-2": {"hostname": "eim.us-east-2.outscale.com"},
"us-west-1": {"hostname": "eim.us-west-1.outscale.com"},
"ap-northeast-1": {"hostname": "eim.ap-northeast-1.outscale.com"}
}
},
"directconnect": {
"endpoints": {
"eu-west-2": {"hostname": "directlink.eu-west-2.outscale.com"},
"cloudgouv-eu-west-1": {"hostname": "directlink.cloudgouv-eu-west-1.outscale.com"},
"us-east-2": {"hostname": "directlink.us-east-2.outscale.com"},
"us-west-1": {"hostname": "directlink.us-west-1.outscale.com"}
}
},
"s3": {
"endpoints": {
"eu-west-2": {"hostname": "oos.eu-west-2.outscale.com"},
"cloudgouv-eu-west-1": {"hostname": "oos.cloudgouv-eu-west-1.outscale.com"},
"us-east-2": {"hostname": "oos.us-east-2.outscale.com"},
"us-west-1": {"hostname": "oos.us-west-1.outscale.com"}
}
}
}
}
],
"version": 3
}
En utilisant ce nouveau modèle, votre requête AWS CLI aura un nouveau format :
$ aws ec2 describe-instances --instance-ids i-12345678 i-87654321 i-12348765 i-56784321 --endpoint https://fcu.eu-west-2.outscale.com
$ aws ec2 describe-instances --instance-ids i-12345678 i-87654321 i-12348765 i-56784321
Vous devrez utiliser le paramètre |
Page connexe
AWS™ et Amazon Web Services™ sont des marques de commerce d'Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.