Where are AWS EC2 Availability Zones exactly? - amazon-web-services
I am trying to create a server with the lowest possible latency for my target audience. I get the difference between regions and Availability Zones (I think). It sounds like the Availability Zones are in different cities. Where are they exactly?
The best that Amazon provide in terms of public information is on their EC2 FAQ. If you want the lowest possible latency can you not just ping servers in each availability zone from your target location and find the lowest latency that way? There's no guarantee that physical proximity == lowest latency anyway.
You can assume that all availability zones in the same region have the similar latency. (as they are all very close). Also as far as I know not necessary the availability zones are the same for all users. (i.e. us-east-1a can be different datacenter for different users)
To achieve the optimum experience for your users, you should pick the region that's geographically closest to your users. EC2 Availability Zones within an AWS Region should offer effectively the same latency to external users (as opposed to other services deployed within the same region or AZ as your own service). All AZs are highly interconnected to the Internet infrastructure in their geographic region. Within that region, you ideally want to architect your application so that its components are replicated across multiple AZs to achieve the best possible availability.
As the name suggests, Availability Zones are primarily an availability/reliability construct: by deploying your application across multiple AZs, you can protect yourself against certain failure modes. The promise that AWS EC2 makes to customers is that no two AZs should fail at the same time for related reasons.
Availability Zones comprise of one or more data centres within close proximity such that the latency is low enough for highly distributed applications to operate effectively at "local network" speeds. A region is a collection of such AZs in close enough proximity to one another. However, since they need to be meaningfully separated from one another by distance, the speed of light implies a higher minimum latency across AZs. Peter DeSantis breaks it down very well in his re:Invent 2018 keynote.
This is technically inaccurate but may be a helpful simplified model: you can think of AZs as "logical data centres" and regions as "groups of data centres within the same metro area". Features like synchronous replication might work great within an AZ, but you should probably be more careful creating topologies that span across AZs for example. Conversely, for cluster applications that are extremely latency-sensitive, such as message-passing compute grids, you can optionally use EC2 Placement Groups to ensure the best possible locality inside an AZ's internal topology. The exact latency numbers will vary between regions and you should do your own measurements to inform your architecture decisions.
if you query an ip address to location mapping service for a bunch of instances started in different availability zones, you will end up with a mapping similar to this:
- az: af-south-1c
longitude: 18.424100875854492
latitude: -33.92490005493164
continent:
code: AF
name: Africa
country:
code: ZA
name: South Africa
flag: "\U0001F1FF\U0001F1E6"
region:
code: WC
name: Western Cape
city:
name: Cape Town
postcode: 8001
- az: ap-northeast-1a
longitude: 139.73855590820312
latitude: 35.69628143310547
continent:
code: AS
name: Asia
country:
code: JP
name: Japan
flag: "\U0001F1EF\U0001F1F5"
region:
code: 13
name: Tokyo
city:
name: Tokyo
postcode: 162-0843
- az: ap-northeast-1c
longitude: 139.73855590820312
latitude: 35.69628143310547
continent:
code: AS
name: Asia
country:
code: JP
name: Japan
flag: "\U0001F1EF\U0001F1F5"
region:
code: 13
name: Tokyo
city:
name: Tokyo
postcode: 162-0843
- az: ap-northeast-1d
longitude: 139.73855590820312
latitude: 35.69628143310547
continent:
code: AS
name: Asia
country:
code: JP
name: Japan
flag: "\U0001F1EF\U0001F1F5"
region:
code: 13
name: Tokyo
city:
name: Tokyo
postcode: 162-0843
- az: ap-northeast-2a
longitude: 126.620361328125
latitude: 37.473548889160156
continent:
code: AS
name: Asia
country:
code: KR
name: South Korea
flag: "\U0001F1F0\U0001F1F7"
region:
code: 28
name: Incheon
city:
name: Incheon
postcode: 400-011
- az: ap-northeast-3c
longitude: 135.50750732421875
latitude: 34.67094039916992
continent:
code: AS
name: Asia
country:
code: JP
name: Japan
flag: "\U0001F1EF\U0001F1F5"
region:
code: 27
name: Ōsaka
city:
name: Osaka
postcode: 542-0082
- az: ap-southeast-1a
longitude: 103.8517837524414
latitude: 1.287950038909912
continent:
code: AS
name: Asia
country:
code: SG
name: Singapore
flag: "\U0001F1F8\U0001F1EC"
region:
code: 1
name: Central Singapore
city:
name: Singapore
postcode: null
- az: ap-southeast-1c
longitude: -73.44097137451172
latitude: 41.126861572265625
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: CT
name: Connecticut
city:
name: East Norwalk
postcode: 06850
- az: ap-southeast-2a
longitude: 151.2071075439453
latitude: -33.86714172363281
continent:
code: OC
name: Oceania
country:
code: AU
name: Australia
flag: "\U0001F1E6\U0001F1FA"
region:
code: NSW
name: New South Wales
city:
name: Sydney
postcode: 2000
- az: ap-southeast-2b
longitude: 151.2071075439453
latitude: -33.86714172363281
continent:
code: OC
name: Oceania
country:
code: AU
name: Australia
flag: "\U0001F1E6\U0001F1FA"
region:
code: NSW
name: New South Wales
city:
name: Sydney
postcode: 2000
- az: ca-central-1a
longitude: -73.56201171875
latitude: 45.502079010009766
continent:
code: NA
name: North America
country:
code: CA
name: Canada
flag: "\U0001F1E8\U0001F1E6"
region:
code: QC
name: Quebec
city:
name: Montréal
postcode: H2Y 2J7
- az: ca-central-1b
longitude: -73.56201171875
latitude: 45.502079010009766
continent:
code: NA
name: North America
country:
code: CA
name: Canada
flag: "\U0001F1E8\U0001F1E6"
region:
code: QC
name: Quebec
city:
name: Montréal
postcode: H2Y 2J7
- az: eu-central-1c
longitude: 8.682100296020508
latitude: 50.11090087890625
continent:
code: EU
name: Europe
country:
code: DE
name: Germany
flag: "\U0001F1E9\U0001F1EA"
region:
code: HE
name: Hesse
city:
name: Frankfurt am Main
postcode: 60311
- az: eu-north-1a
longitude: 18.051319122314453
latitude: 59.315120697021484
continent:
code: EU
name: Europe
country:
code: SE
name: Sweden
flag: "\U0001F1F8\U0001F1EA"
region:
code: AB
name: Stockholm
city:
name: Stockholm
postcode: 118 58
- az: eu-north-1b
longitude: 18.051319122314453
latitude: 59.315120697021484
continent:
code: EU
name: Europe
country:
code: SE
name: Sweden
flag: "\U0001F1F8\U0001F1EA"
region:
code: AB
name: Stockholm
city:
name: Stockholm
postcode: 118 58
- az: eu-north-1c
longitude: 18.051319122314453
latitude: 59.315120697021484
continent:
code: EU
name: Europe
country:
code: SE
name: Sweden
flag: "\U0001F1F8\U0001F1EA"
region:
code: AB
name: Stockholm
city:
name: Stockholm
postcode: 118 58
- az: eu-south-1a
longitude: 9.192000389099121
latitude: 45.47200012207031
continent:
code: EU
name: Europe
country:
code: IT
name: Italy
flag: "\U0001F1EE\U0001F1F9"
region:
code: 25
name: Lombardy
city:
name: Milan
postcode: 20121
- az: eu-south-1b
longitude: 9.192000389099121
latitude: 45.47200012207031
continent:
code: EU
name: Europe
country:
code: IT
name: Italy
flag: "\U0001F1EE\U0001F1F9"
region:
code: 25
name: Lombardy
city:
name: Milan
postcode: 20121
- az: eu-south-1b
longitude: 9.192899703979492
latitude: 45.48379898071289
continent:
code: EU
name: Europe
country:
code: IT
name: Italy
flag: "\U0001F1EE\U0001F1F9"
region:
code: 25
name: Lombardy
city:
name: Milan
postcode: 20124
- az: eu-south-1c
longitude: 9.192000389099121
latitude: 45.47200012207031
continent:
code: EU
name: Europe
country:
code: IT
name: Italy
flag: "\U0001F1EE\U0001F1F9"
region:
code: 25
name: Lombardy
city:
name: Milan
postcode: 20121
- az: eu-west-1a
longitude: -6.243330001831055
latitude: 53.35388946533203
continent:
code: EU
name: Europe
country:
code: IE
name: Ireland
flag: "\U0001F1EE\U0001F1EA"
region:
code: L
name: Leinster
city:
name: Dublin
postcode: null
- az: eu-west-1b
longitude: -6.243330001831055
latitude: 53.35388946533203
continent:
code: EU
name: Europe
country:
code: IE
name: Ireland
flag: "\U0001F1EE\U0001F1EA"
region:
code: L
name: Leinster
city:
name: Dublin
postcode: null
- az: eu-west-1c
longitude: -6.243330001831055
latitude: 53.35388946533203
continent:
code: EU
name: Europe
country:
code: IE
name: Ireland
flag: "\U0001F1EE\U0001F1EA"
region:
code: L
name: Leinster
city:
name: Dublin
postcode: null
- az: eu-west-2c
longitude: -0.12574
latitude: 51.5122184753418
continent:
code: EU
name: Europe
country:
code: GB
name: United Kingdom
flag: "\U0001F1EC\U0001F1E7"
region:
code: ENG
name: England
city:
name: Blackheath
postcode: EC1M
- az: eu-west-2c
longitude: 0
latitude: 51.5122184753418
continent:
code: EU
name: Europe
country:
code: GB
name: United Kingdom
flag: "\U0001F1EC\U0001F1E7"
region:
code: ENG
name: England
city:
name: Blackheath
postcode: EC1M
- az: eu-west-3a
longitude: 2.3410699367523193
latitude: 48.8602294921875
continent:
code: EU
name: Europe
country:
code: FR
name: France
flag: "\U0001F1EB\U0001F1F7"
region:
code: IDF
name: Île-de-France
city:
name: Saint-Ouen
postcode: 75001
- az: eu-west-3c
longitude: 2.3410699367523193
latitude: 48.8602294921875
continent:
code: EU
name: Europe
country:
code: FR
name: France
flag: "\U0001F1EB\U0001F1F7"
region:
code: IDF
name: Île-de-France
city:
name: Saint-Ouen
postcode: 75001
- az: us-east-1b
longitude: -77.47419738769531
latitude: 39.043701171875
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: VA
name: Virginia
city:
name: Ashburn
postcode: 20147
- az: us-east-1c
longitude: -77.47419738769531
latitude: 39.043701171875
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: VA
name: Virginia
city:
name: Ashburn
postcode: 20147
- az: us-east-1d
longitude: -77.47419738769531
latitude: 39.043701171875
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: VA
name: Virginia
city:
name: Ashburn
postcode: 20147
- az: us-east-1f
longitude: -77.47419738769531
latitude: 39.043701171875
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: VA
name: Virginia
city:
name: Ashburn
postcode: 20147
- az: us-east-2b
longitude: -82.99945831298828
latitude: 39.99557876586914
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: OH
name: Ohio
city:
name: Columbus
postcode: 43201
- az: us-east-2c
longitude: -82.99945831298828
latitude: 39.99557876586914
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: OH
name: Ohio
city:
name: Columbus
postcode: 43201
- az: us-west-1a
longitude: -121.83822631835938
latitude: 37.330528259277344
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: CA
name: California
city:
name: San Jose
postcode: 95122
- az: us-west-1b
longitude: -121.83822631835938
latitude: 37.330528259277344
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: CA
name: California
city:
name: San Jose
postcode: 95122
- az: us-west-2d
longitude: -119.81143188476562
latitude: 45.73722839355469
continent:
code: NA
name: North America
country:
code: US
name: United States
flag: "\U0001F1FA\U0001F1F8"
region:
code: OR
name: Oregon
city:
name: Boardman
postcode: 97818
[
{
"az": "af-south-1c",
"longitude": 18.424100875854492,
"latitude": -33.92490005493164,
"continent": {
"code": "AF",
"name": "Africa"
},
"country": {
"code": "ZA",
"name": "South Africa",
"flag": "🇿🇦"
},
"region": {
"code": "WC",
"name": "Western Cape"
},
"city": {
"name": "Cape Town"
},
"postcode": 8001
},
{
"az": "ap-northeast-1a",
"longitude": 139.73855590820312,
"latitude": 35.69628143310547,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "JP",
"name": "Japan",
"flag": "🇯🇵"
},
"region": {
"code": 13,
"name": "Tokyo"
},
"city": {
"name": "Tokyo"
},
"postcode": "162-0843"
},
{
"az": "ap-northeast-1c",
"longitude": 139.73855590820312,
"latitude": 35.69628143310547,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "JP",
"name": "Japan",
"flag": "🇯🇵"
},
"region": {
"code": 13,
"name": "Tokyo"
},
"city": {
"name": "Tokyo"
},
"postcode": "162-0843"
},
{
"az": "ap-northeast-1d",
"longitude": 139.73855590820312,
"latitude": 35.69628143310547,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "JP",
"name": "Japan",
"flag": "🇯🇵"
},
"region": {
"code": 13,
"name": "Tokyo"
},
"city": {
"name": "Tokyo"
},
"postcode": "162-0843"
},
{
"az": "ap-northeast-2a",
"longitude": 126.620361328125,
"latitude": 37.473548889160156,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "KR",
"name": "South Korea",
"flag": "🇰🇷"
},
"region": {
"code": 28,
"name": "Incheon"
},
"city": {
"name": "Incheon"
},
"postcode": "400-011"
},
{
"az": "ap-northeast-3c",
"longitude": 135.50750732421875,
"latitude": 34.67094039916992,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "JP",
"name": "Japan",
"flag": "🇯🇵"
},
"region": {
"code": 27,
"name": "Ōsaka"
},
"city": {
"name": "Osaka"
},
"postcode": "542-0082"
},
{
"az": "ap-southeast-1a",
"longitude": 103.8517837524414,
"latitude": 1.287950038909912,
"continent": {
"code": "AS",
"name": "Asia"
},
"country": {
"code": "SG",
"name": "Singapore",
"flag": "🇸🇬"
},
"region": {
"code": 1,
"name": "Central Singapore"
},
"city": {
"name": "Singapore"
},
"postcode": null
},
{
"az": "ap-southeast-1c",
"longitude": -73.44097137451172,
"latitude": 41.126861572265625,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "CT",
"name": "Connecticut"
},
"city": {
"name": "East Norwalk"
},
"postcode": "06850"
},
{
"az": "ap-southeast-2a",
"longitude": 151.2071075439453,
"latitude": -33.86714172363281,
"continent": {
"code": "OC",
"name": "Oceania"
},
"country": {
"code": "AU",
"name": "Australia",
"flag": "🇦🇺"
},
"region": {
"code": "NSW",
"name": "New South Wales"
},
"city": {
"name": "Sydney"
},
"postcode": 2000
},
{
"az": "ap-southeast-2b",
"longitude": 151.2071075439453,
"latitude": -33.86714172363281,
"continent": {
"code": "OC",
"name": "Oceania"
},
"country": {
"code": "AU",
"name": "Australia",
"flag": "🇦🇺"
},
"region": {
"code": "NSW",
"name": "New South Wales"
},
"city": {
"name": "Sydney"
},
"postcode": 2000
},
{
"az": "ca-central-1a",
"longitude": -73.56201171875,
"latitude": 45.502079010009766,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "CA",
"name": "Canada",
"flag": "🇨🇦"
},
"region": {
"code": "QC",
"name": "Quebec"
},
"city": {
"name": "Montréal"
},
"postcode": "H2Y 2J7"
},
{
"az": "ca-central-1b",
"longitude": -73.56201171875,
"latitude": 45.502079010009766,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "CA",
"name": "Canada",
"flag": "🇨🇦"
},
"region": {
"code": "QC",
"name": "Quebec"
},
"city": {
"name": "Montréal"
},
"postcode": "H2Y 2J7"
},
{
"az": "eu-central-1c",
"longitude": 8.682100296020508,
"latitude": 50.11090087890625,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "DE",
"name": "Germany",
"flag": "🇩🇪"
},
"region": {
"code": "HE",
"name": "Hesse"
},
"city": {
"name": "Frankfurt am Main"
},
"postcode": 60311
},
{
"az": "eu-north-1a",
"longitude": 18.051319122314453,
"latitude": 59.315120697021484,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "SE",
"name": "Sweden",
"flag": "🇸🇪"
},
"region": {
"code": "AB",
"name": "Stockholm"
},
"city": {
"name": "Stockholm"
},
"postcode": "118 58"
},
{
"az": "eu-north-1b",
"longitude": 18.051319122314453,
"latitude": 59.315120697021484,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "SE",
"name": "Sweden",
"flag": "🇸🇪"
},
"region": {
"code": "AB",
"name": "Stockholm"
},
"city": {
"name": "Stockholm"
},
"postcode": "118 58"
},
{
"az": "eu-north-1c",
"longitude": 18.051319122314453,
"latitude": 59.315120697021484,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "SE",
"name": "Sweden",
"flag": "🇸🇪"
},
"region": {
"code": "AB",
"name": "Stockholm"
},
"city": {
"name": "Stockholm"
},
"postcode": "118 58"
},
{
"az": "eu-south-1a",
"longitude": 9.192000389099121,
"latitude": 45.47200012207031,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IT",
"name": "Italy",
"flag": "🇮🇹"
},
"region": {
"code": 25,
"name": "Lombardy"
},
"city": {
"name": "Milan"
},
"postcode": 20121
},
{
"az": "eu-south-1b",
"longitude": 9.192000389099121,
"latitude": 45.47200012207031,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IT",
"name": "Italy",
"flag": "🇮🇹"
},
"region": {
"code": 25,
"name": "Lombardy"
},
"city": {
"name": "Milan"
},
"postcode": 20121
},
{
"az": "eu-south-1b",
"longitude": 9.192899703979492,
"latitude": 45.48379898071289,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IT",
"name": "Italy",
"flag": "🇮🇹"
},
"region": {
"code": 25,
"name": "Lombardy"
},
"city": {
"name": "Milan"
},
"postcode": 20124
},
{
"az": "eu-south-1c",
"longitude": 9.192000389099121,
"latitude": 45.47200012207031,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IT",
"name": "Italy",
"flag": "🇮🇹"
},
"region": {
"code": 25,
"name": "Lombardy"
},
"city": {
"name": "Milan"
},
"postcode": 20121
},
{
"az": "eu-west-1a",
"longitude": -6.243330001831055,
"latitude": 53.35388946533203,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IE",
"name": "Ireland",
"flag": "🇮🇪"
},
"region": {
"code": "L",
"name": "Leinster"
},
"city": {
"name": "Dublin"
},
"postcode": null
},
{
"az": "eu-west-1b",
"longitude": -6.243330001831055,
"latitude": 53.35388946533203,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IE",
"name": "Ireland",
"flag": "🇮🇪"
},
"region": {
"code": "L",
"name": "Leinster"
},
"city": {
"name": "Dublin"
},
"postcode": null
},
{
"az": "eu-west-1c",
"longitude": -6.243330001831055,
"latitude": 53.35388946533203,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "IE",
"name": "Ireland",
"flag": "🇮🇪"
},
"region": {
"code": "L",
"name": "Leinster"
},
"city": {
"name": "Dublin"
},
"postcode": null
},
{
"az": "eu-west-2c",
"longitude": -0.12574,
"latitude": 51.5122184753418,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "GB",
"name": "United Kingdom",
"flag": "🇬🇧"
},
"region": {
"code": "ENG",
"name": "England"
},
"city": {
"name": "Blackheath"
},
"postcode": "EC1M"
},
{
"az": "eu-west-2c",
"longitude": 0,
"latitude": 51.5122184753418,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "GB",
"name": "United Kingdom",
"flag": "🇬🇧"
},
"region": {
"code": "ENG",
"name": "England"
},
"city": {
"name": "Blackheath"
},
"postcode": "EC1M"
},
{
"az": "eu-west-3a",
"longitude": 2.3410699367523193,
"latitude": 48.8602294921875,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "FR",
"name": "France",
"flag": "🇫🇷"
},
"region": {
"code": "IDF",
"name": "Île-de-France"
},
"city": {
"name": "Saint-Ouen"
},
"postcode": 75001
},
{
"az": "eu-west-3c",
"longitude": 2.3410699367523193,
"latitude": 48.8602294921875,
"continent": {
"code": "EU",
"name": "Europe"
},
"country": {
"code": "FR",
"name": "France",
"flag": "🇫🇷"
},
"region": {
"code": "IDF",
"name": "Île-de-France"
},
"city": {
"name": "Saint-Ouen"
},
"postcode": 75001
},
{
"az": "us-east-1b",
"longitude": -77.47419738769531,
"latitude": 39.043701171875,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "VA",
"name": "Virginia"
},
"city": {
"name": "Ashburn"
},
"postcode": 20147
},
{
"az": "us-east-1c",
"longitude": -77.47419738769531,
"latitude": 39.043701171875,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "VA",
"name": "Virginia"
},
"city": {
"name": "Ashburn"
},
"postcode": 20147
},
{
"az": "us-east-1d",
"longitude": -77.47419738769531,
"latitude": 39.043701171875,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "VA",
"name": "Virginia"
},
"city": {
"name": "Ashburn"
},
"postcode": 20147
},
{
"az": "us-east-1f",
"longitude": -77.47419738769531,
"latitude": 39.043701171875,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "VA",
"name": "Virginia"
},
"city": {
"name": "Ashburn"
},
"postcode": 20147
},
{
"az": "us-east-2b",
"longitude": -82.99945831298828,
"latitude": 39.99557876586914,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "OH",
"name": "Ohio"
},
"city": {
"name": "Columbus"
},
"postcode": 43201
},
{
"az": "us-east-2c",
"longitude": -82.99945831298828,
"latitude": 39.99557876586914,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "OH",
"name": "Ohio"
},
"city": {
"name": "Columbus"
},
"postcode": 43201
},
{
"az": "us-west-1a",
"longitude": -121.83822631835938,
"latitude": 37.330528259277344,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "CA",
"name": "California"
},
"city": {
"name": "San Jose"
},
"postcode": 95122
},
{
"az": "us-west-1b",
"longitude": -121.83822631835938,
"latitude": 37.330528259277344,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "CA",
"name": "California"
},
"city": {
"name": "San Jose"
},
"postcode": 95122
},
{
"az": "us-west-2d",
"longitude": -119.81143188476562,
"latitude": 45.73722839355469,
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"flag": "🇺🇸"
},
"region": {
"code": "OR",
"name": "Oregon"
},
"city": {
"name": "Boardman"
},
"postcode": 97818
}
]
note that this is not an accurate representation of az locations. it's just the result of running geolocation queries against the public ip addresses of multiple ec2 instances.
You can read on this Amazon doc page that Availability Zones are not map to a specific place :
To ensure that resources are distributed across the Availability Zones for a region, we independently map Availability Zones to identifiers for each account. For example, your Availability Zone us-east-1a might not be the same location as us-east-1a for another account. Note that there's no way for you to coordinate Availability Zones between accounts.
UPADTE : according to Pavel comment below, please note that now you can use unique identifier for availability zone AZ ID :
To coordinate Availability Zones across accounts, you must use the AZ ID, which is a unique and consistent identifier for an Availability Zone. For example, use1-az1 is an AZ ID for the us-east-1 Region and it has the same location in every AWS account.
Source aws documentation
Related
Retrieve nested value on a list in Ansible
I am producing from VMware datastores collection a list of volumes and their associated tags I formated them in a JSON type output to be able to feed another system later. The output is working but for the tags section I would like to keep only the name and category_name not the other properties. This is my playbook : --- - name: Fetching Datastores hosts: localhost tasks: - name: Gather info from datacenter about specific datastore community.vmware.vmware_datastore_info: hostname: 'myesxiHost' username: 'administrator' password: 'Password' validate_certs: False show_tag: true delegate_to: localhost register: ds_info - set_fact: ds_info_eph: "{{ ds_info_eph|default([]) + [ { 'name': item.name, 'type': item.type, 'capacity': item.capacity, 'tag': item.tags } ] }}" loop: "{{ ds_info.datastores }}" - name: Output info debug: msg: "{{ ds_info_eph }}" This playbook give me the following output : ok: [localhost] => { "msg": [ { "capacity": 499826819072, "name": "ESX01_SSD4", "tag": [ { "category_id": "urn:vmomi:InventoryServiceCategory:017ad796-b931-4f5b-bd4a-8fee7adaf124:GLOBAL", "category_name": "Tier", "description": "", "id": "urn:vmomi:InventoryServiceTag:6112eeac-ed81-48d4-b7d9-81084b8a415a:GLOBAL", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 499826819072, "name": "ESX01_SSD3", "tag": [ { "category_id": "urn:vmomi:InventoryServiceCategory:017ad796-b931-4f5b-bd4a-8fee7adaf124:GLOBAL", "category_name": "Tier", "description": "", "id": "urn:vmomi:InventoryServiceTag:6112eeac-ed81-48d4-b7d9-81084b8a415a:GLOBAL", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 499826819072, "name": "ESX01_SSD5", "tag": [ { "category_id": "urn:vmomi:InventoryServiceCategory:017ad796-b931-4f5b-bd4a-8fee7adaf124:GLOBAL", "category_name": "Tier", "description": "", "id": "urn:vmomi:InventoryServiceTag:6112eeac-ed81-48d4-b7d9-81084b8a415a:GLOBAL", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 239981297664, "name": "ESX01_SSD2", "tag": [ { "category_id": "urn:vmomi:InventoryServiceCategory:017ad796-b931-4f5b-bd4a-8fee7adaf124:GLOBAL", "category_name": "Tier", "description": "", "id": "urn:vmomi:InventoryServiceTag:6112eeac-ed81-48d4-b7d9-81084b8a415a:GLOBAL", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 248034361344, "name": "ESX01_SSD1", "tag": [ { "category_id": "urn:vmomi:InventoryServiceCategory:017ad796-b931-4f5b-bd4a-8fee7adaf124:GLOBAL", "category_name": "Tier", "description": "", "id": "urn:vmomi:InventoryServiceTag:6112eeac-ed81-48d4-b7d9-81084b8a415a:GLOBAL", "name": "Gold" } ], "type": "VMFS" } ] } Instead I would like to have this output : ok: [localhost] => { "msg": [ { "capacity": 499826819072, "name": "ESX01_SSD4", "tag": [ { "category_name": "Tier", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 499826819072, "name": "ESX01_SSD3", "tag": [ { "category_name": "Tier", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 499826819072, "name": "ESX01_SSD5", "tag": [ { "category_name": "Tier", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 239981297664, "name": "ESX01_SSD2", "tag": [ { "category_name": "Tier", "name": "Gold" } ], "type": "VMFS" }, { "capacity": 248034361344, "name": "ESX01_SSD1", "tag": [ { "category_name": "Tier", "name": "Gold" } ], "type": "VMFS" } ] } But on the tag section I tried to do in the playbook the following to get only the name and not all the tag item list : 'tag': item.tags.name but I'v got the following error fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ ds_info_eph|default([]) + [ { 'name': item.name, 'type': item.type, 'capacity': item.capacity, 'tag': item.tags.name } ] }}): can only concatenate str (not \"list\") to str"} My understanding is somehow in that set_fac I have to loop again to get only the tag name and tag category_name but I didn't figure out how to. Thank you for your help !
Select the attributes from the tag lists, e.g. - set_fact: _tags: "{{ ds_info_eph| map(attribute='tag')| map('items2dict', 'category_name', 'name')}}" gives _tags: - Tier: Gold - Tier: Gold - Tier: Gold - Tier: Gold - Tier: Gold Combine the dictionaries - set_fact: result: "{{ result|d([]) + [item.0|combine({'tag': item.1})] }}" with_together: - "{{ ds_info_eph }}" - "{{ _tags|map('dict2items', 'category_name', 'name') }}" gives result: - capacity: 499826819072 name: ESX01_SSD4 tag: category_name: Tier name: Gold type: VMFS - capacity: 499826819072 name: ESX01_SSD3 tag: category_name: Tier name: Gold type: VMFS - capacity: 499826819072 name: ESX01_SSD5 tag: category_name: Tier name: Gold type: VMFS - capacity: 239981297664 name: ESX01_SSD2 tag: category_name: Tier name: Gold type: VMFS - capacity: 248034361344 name: ESX01_SSD1 tag: category_name: Tier name: Gold type: VMFS
"Buffalo" query fails to return "Buffalo Exchange" from /discover endpoint
NOTE: this question is specifically for support staff of the HERE Developer API because they ask freemium users to post support questions on Stack Overflow rather than trying to contact them directly. If you're not a member of their staff and you're unable to help or if the question is unclear to you, don't worry about it. :) For some reason the /discover endpoint doesn't return the "Buffalo Exchange" place that's at my specified coordinates, but only returns 2 localities that are much further away. This is the query that I'm using: https://discover.search.hereapi.com/v1/discover?at=34.003975%2C-118.484823&q=Buffalo&limit=20&apiKey=<insert API KEY>. These are the results I currently receive: { "items": [ { "title": "Buffalo, NY, United States", "id": "here:cm:namedplace:21018816", "resultType": "locality", "localityType": "city", "address": { "label": "Buffalo, NY, United States", "countryCode": "USA", "countryName": "United States", "stateCode": "NY", "state": "New York", "county": "Erie", "city": "Buffalo", "postalCode": "14202" }, "position": { "lat": 42.88544, "lng": -78.87846 }, "distance": 3551940, "mapView": { "west": -78.9168, "south": 42.82603, "east": -78.79492, "north": 42.96651 } }, { "title": "Buffalo City, Eastern Cape, South Africa", "id": "here:cm:namedplace:23402337", "resultType": "locality", "localityType": "city", "address": { "label": "Buffalo City, Eastern Cape, South Africa", "countryCode": "ZAF", "countryName": "South Africa", "state": "Eastern Cape", "county": "Buffalo City", "city": "Buffalo City", "postalCode": "5201" }, "position": { "lat": -33.0148, "lng": 27.9038 }, "distance": 16910944, "mapView": { "west": 27.15745, "south": -33.28749, "east": 28.08053, "north": -32.674 } } ] } You can see that for both places the resultType is "locality". Now compare that to the first result of a similar query that searches for the term "Exchange" instead of "Buffalo". All other query params are the same. This is the URL: https://discover.search.hereapi.com/v1/discover?at=34.003975%2C-118.484823&q=Exchange&limit=20&apiKey=<insert API KEY>, and this is how the results begin (not shown fully because there are many results): { "items": [ { "title": "Buffalo Exchange", "id": "here:pds:place:8403fv6k-b15f290ec4f409deea99318f7388bbd6", "resultType": "place", "address": { "label": "Buffalo Exchange, 2449 Main St, Santa Monica, CA 90405, United States", "countryCode": "USA", "countryName": "United States", "stateCode": "CA", "state": "California", "county": "Los Angeles", "city": "Santa Monica", "district": "City of Santa Monica", "street": "Main St", "postalCode": "90405", "houseNumber": "2449" }, "position": { "lat": 34.00342, "lng": -118.48483 }, "access": [ { "lat": 34.00331, "lng": -118.48493 } ], "distance": 61, "categories": [ { "id": "600-6800-0090", "name": "Women's Apparel", "primary": true }, { "id": "600-6800-0000", "name": "Clothing & Accessories" }, { "id": "600-6800-0089", "name": "Men's Apparel" }, { "id": "600-6900-0251", "name": "Used/Second-hand Merchandise Stores" } ], "references": [ { "supplier": { "id": "core" }, "id": "1211447153" }, { "supplier": { "id": "yelp" }, "id": "5PzeN6hGLBPmJpCJ2ZmfCQ" } ], "contacts": [ { "phone": [ { "value": "+13103147300" }, { "value": "+13103924301", "categories": [ { "id": "600-6800-0000" } ] } ], "fax": [ { "value": "(520) 622-7015", "categories": [ { "id": "600-6800-0000" } ] } ], "www": [ { "value": "http://www.buffaloexchange.com", "categories": [ { "id": "600-6800-0000" }, { "id": "600-6900-0251" } ] } ], "email": [ { "value": "contact#bufex.com", "categories": [ { "id": "600-6800-0000" } ] } ] } ], "openingHours": [ { "categories": [ { "id": "600-6800-0000" } ], "text": [ "Mon-Sun: 11:00 - 20:00" ], "isOpen": false, "structured": [ { "start": "T110000", "duration": "PT09H00M", "recurrence": "FREQ:DAILY;BYDAY:MO,TU,WE,TH,FR,SA,SU" } ] }, { "categories": [ { "id": "600-6800-0090" }, { "id": "600-6900-0251" } ], "text": [ "Mon-Sat: 11:00 - 20:00", "Sun: 11:00 - 19:00" ], "isOpen": false, "structured": [ { "start": "T110000", "duration": "PT09H00M", "recurrence": "FREQ:DAILY;BYDAY:MO,TU,WE,TH,FR,SA" }, { "start": "T110000", "duration": "PT08H00M", "recurrence": "FREQ:DAILY;BYDAY:SU" } ] } ] }, ... } You can see that the first result has the name "Buffalo Exchange" and the "resultType" is "place". This is the result I want. The question is why does this result fail to show up when the search query is "Buffalo"? Of course with the /discover endpoint I can't specify the category IDs I want to search, that's only available via the /browse endpoint. But with the /browse endpoint I can't specify a specific search term like "Buffalo" or "Exchange". Update: this problem also happens with the "Bison" query in Alberta, Canada. The query for this is https://discover.search.hereapi.com/v1/discover?at=56.745531%2C-111.351341&q=Exchange&limit=20&apiKey=<insert API KEY>. This query yields only 10 results, and only 4 of them have resultType of "place".
We recommend application developers to use both Autosuggest and Discover, you get the nearby Buffalo Exchange because Autosuggest considers that the query is incomplete. Note that Discover considers the query to be complete. As HERE Geocoding and Search is meant to provide relevant responses to user queries. Geocoding Search Api (Autosuggest): https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html Geocoding Search Api (Discover): https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-discover-brief.html The above-mentioned user guide can help modify the query for accurate results.
Wrong geocode results
We're trying to geocode a location in Poland, using a street, zip code and a city name, but seem to get wrong result. We're looking for: DĄBROWSKIEGO , 82-300 ELBLĄG Request: https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey={API_KEY}&searchtext=D%C4%84BROWSKIEGO%2B,%2B82-300%2BELBL%C4%84G Instead of a road of that name in the city of Elbląg we get a street of the same name in Poznań: { "Response": { "MetaInfo": { "Timestamp": "2021-05-11T10:40:48.113+0000" }, "View": [ { "Result": [ { "Relevance": 0.65, "MatchLevel": "houseNumber", "MatchQuality": { "Street": [ 0.5 ], "HouseNumber": 1.0 }, "MatchType": "pointAddress", "Location": { "LocationId": "here:af:streetsection:nKjv5QtDTbhcQ-QErVaJvA:CgcIBCDCwO9pEAEaAzMwMA", "LocationType": "point", "DisplayPosition": { "Latitude": 52.42663, "Longitude": 16.85675 }, "NavigationPosition": [ { "Latitude": 52.42678, "Longitude": 16.85687 } ], "MapView": { "TopLeft": { "Latitude": 52.42753, "Longitude": 16.85528 }, "BottomRight": { "Latitude": 52.42573, "Longitude": 16.85822 } }, "Address": { "Label": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska", "Country": "POL", "State": "Woj. Wielkopolskie", "County": "Poznań", "City": "Poznań", "District": "Poznań", "Subdistrict": "Jeżyce", "Street": "ulica gen. Jana H. Dąbrowskiego", "HouseNumber": "300", "PostalCode": "60-406", "AdditionalData": [ { "value": "Polska", "key": "CountryName" }, { "value": "Woj. Wielkopolskie", "key": "StateName" }, { "value": "Poznań", "key": "CountyName" } ] } } } ], "ViewId": 0 } ] } } Trying to use newer api gives the same results: https://geocode.search.hereapi.com/v1/geocode?apiKey={API_KEY}&q=D%C4%84BROWSKIEGO%2B,%2B82-300%2BELBL%C4%84G { "items": [ { "title": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska", "id": "here:af:streetsection:nKjv5QtDTbhcQ-QErVaJvA:CgcIBCDCwO9pEAEaAzMwMA", "resultType": "houseNumber", "houseNumberType": "PA", "address": { "label": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska", "countryCode": "POL", "countryName": "Polska", "state": "Woj. Wielkopolskie", "county": "Poznań", "city": "Poznań", "district": "Poznań", "subdistrict": "Jeżyce", "street": "ulica gen. Jana H. Dąbrowskiego", "postalCode": "60-406", "houseNumber": "300" }, "position": { "lat": 52.42663, "lng": 16.85675 }, "access": [ { "lat": 52.42678, "lng": 16.85687 } ], "mapView": { "west": 16.85528, "south": 52.42573, "east": 16.85822, "north": 52.42753 }, "scoring": { "queryScore": 0.65, "fieldScore": { "streets": [ 0.5 ], "houseNumber": 1.0 } } } ] } Looking for a different street in the city of Elbląg gives us proper result: Łęczycka, 82-300 ELBLĄG https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey={API_KEY}&searchtext=%C5%81%C4%99czycka%2B,%2B82-300%2BELBL%C4%84G { "Response": { "MetaInfo": { "Timestamp": "2021-05-11T10:43:15.578+0000" }, "View": [ { "Result": [ { "Relevance": 0.99, "MatchLevel": "street", "MatchQuality": { "City": 1.0, "Street": [ 0.9 ], "PostalCode": 1.0 }, "Location": { "LocationId": "here:af:street:SHP1-8Tzm6jtHKMvaFxTLA", "LocationType": "point", "DisplayPosition": { "Latitude": 54.16571, "Longitude": 19.46824 }, "NavigationPosition": [ { "Latitude": 54.16571, "Longitude": 19.46824 } ], "MapView": { "TopLeft": { "Latitude": 54.17117, "Longitude": 19.43421 }, "BottomRight": { "Latitude": 54.15544, "Longitude": 19.50485 } }, "Address": { "Label": "ulica Łęczycka, 82-300 Elbląg, Polska", "Country": "POL", "State": "Woj. Warmińsko-Mazurskie", "County": "Elbląg", "City": "Elbląg", "District": "Elbląg", "Street": "ulica Łęczycka", "PostalCode": "82-300", "AdditionalData": [ { "value": "Polska", "key": "CountryName" }, { "value": "Woj. Warmińsko-Mazurskie", "key": "StateName" }, { "value": "Elbląg", "key": "CountyName" } ] } } } ], "ViewId": 0 } ] } } Is there anything we're doing wrong when invoking the requests?
Now it returns correct results: https://geocoder.ls.hereapi.com/6.2/geocode.json?language=en-US&maxresults=20&searchtext=D%C4%84BROWSKIEGO+82-300+ELBL%C4%84G&apikey=*** Result: { "Response": { "MetaInfo": { "Timestamp": "2021-07-20T12:23:56.560+0000" }, "View": [ { "_type": "SearchResultsViewType", "ViewId": 0, "Result": [ { "Relevance": 1, "MatchLevel": "street", "MatchQuality": { "City": 1, "Street": [ 0.57 ], "PostalCode": 1 }, "Location": { "LocationId": "NT_mqHTX7fWyBVgpiaYyp.VAB", "LocationType": "point", "DisplayPosition": { "Latitude": 54.15047, "Longitude": 19.45583 }, "NavigationPosition": [ { "Latitude": 54.15047, "Longitude": 19.45583 } ], "MapView": { "TopLeft": { "Latitude": 54.15449, "Longitude": 19.44247 }, "BottomRight": { "Latitude": 54.15029, "Longitude": 19.46051 } }, "Address": { "Label": "ulica gen. Jarosława Dąbrowskiego, 82-300 Elbląg, Poland", "Country": "POL", "State": "Woj. Warmińsko-Mazurskie", "County": "Elbląg", "City": "Elbląg", "District": "Elbląg", "Street": "ulica gen. Jarosława Dąbrowskiego", "PostalCode": "82-300", "AdditionalData": [ { "value": "Poland", "key": "CountryName" }, { "value": "Woj. Warmińsko-Mazurskie", "key": "StateName" }, { "value": "Elbląg", "key": "CountyName" } ] } } } ] } ] } } This GS7 request https://search.hereapi.com/v1/geocode?q=D%C4%84BROWSKIEGO+82-300+ELBL%C4%84G&at=51.9206796%2C17.2954345&lang=en-US&limit=20&apikey=*** returns incorrect result - but will be fixed soon.
How to Implement Partial Auth on Authorize.net API [duplicate]
Okay I am setting up Partial Payments via the Authorize.net API in order to enable multiple cards to be used to cover a single balance/charge. I'm assuming thier Partial Auth feature covers my use case, but in testing, there is an issue I can show you using the API live console here: https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-credit-card Go to the link above and authorize partial payments with the request I edited below and you will notice when you press submit you get a splitTenderId: { "createTransactionRequest": { "merchantAuthentication": { "name": "5KP3u95bQpv", "transactionKey": "346HZ32z3fP4hTG2" }, "refId": "123456", "transactionRequest": { "transactionType": "authCaptureTransaction", "amount": "462.25", "payment": { "creditCard": { "cardNumber": "5424000000000015", "expirationDate": "2020-12", "cardCode": "999" } }, "lineItems": { "lineItem": { "itemId": "1", "name": "vase", "description": "Cannes logo", "quantity": "18", "unitPrice": "45.00" } }, "tax": { "amount": "4.26", "name": "level2 tax name", "description": "level2 tax" }, "duty": { "amount": "8.55", "name": "duty name", "description": "duty description" }, "shipping": { "amount": "4.26", "name": "level2 tax name", "description": "level2 tax" }, "poNumber": "456654", "customer": { "id": "99999456654" }, "billTo": { "firstName": "Ellen", "lastName": "Johnson", "company": "Souveniropolis", "address": "14 Main Street", "city": "Pecan Springs", "state": "TX", "zip": "44628", "country": "USA" }, "shipTo": { "firstName": "China", "lastName": "Bayles", "company": "Thyme for Tea", "address": "12 Main Street", "city": "Pecan Springs", "state": "TX", "zip": "44628", "country": "USA" }, "customerIP": "192.168.1.1", "transactionSettings": { "setting": [ { "settingName": "emailCustomer", "settingValue": "true" }, { "settingName": "allowPartialAuth", "settingValue": "true" }, ] }, "userFields": { "userField": [ { "name": "MerchantDefinedFieldName1", "value": "MerchantDefinedFieldValue1" }, { "name": "favorite_color", "value": "blue" } ] } } } } This is only successful because the amount is 462.25 as the docs say to use for testing, if I use any other (real) amount the splitTenderId is not there. Here is a new example request, you can post this again on the link above: { "createTransactionRequest": { "merchantAuthentication": { "name": "5KP3u95bQpv", "transactionKey": "346HZ32z3fP4hTG2" }, "refId": "123456", "transactionRequest": { "transactionType": "authCaptureTransaction", "amount": "462", "payment": { "creditCard": { "cardNumber": "5424000000000015", "expirationDate": "2020-12", "cardCode": "999" } }, "lineItems": { "lineItem": { "itemId": "1", "name": "vase", "description": "Cannes logo", "quantity": "18", "unitPrice": "45.00" } }, "tax": { "amount": "4.26", "name": "level2 tax name", "description": "level2 tax" }, "duty": { "amount": "8.55", "name": "duty name", "description": "duty description" }, "shipping": { "amount": "4.26", "name": "level2 tax name", "description": "level2 tax" }, "poNumber": "456654", "customer": { "id": "99999456654" }, "billTo": { "firstName": "Ellen", "lastName": "Johnson", "company": "Souveniropolis", "address": "14 Main Street", "city": "Pecan Springs", "state": "TX", "zip": "44628", "country": "USA" }, "shipTo": { "firstName": "China", "lastName": "Bayles", "company": "Thyme for Tea", "address": "12 Main Street", "city": "Pecan Springs", "state": "TX", "zip": "44628", "country": "USA" }, "customerIP": "192.168.1.1", "transactionSettings": { "setting": [ { "settingName": "emailCustomer", "settingValue": "true" }, { "settingName": "allowPartialAuth", "settingValue": "true" }, ] }, "userFields": { "userField": [ { "name": "MerchantDefinedFieldName1", "value": "MerchantDefinedFieldValue1" }, { "name": "favorite_color", "value": "blue" } ] } } } } And with the 462 amount entered this is no longer a partial auth payment and I no longer get a splitTenderId. Can someone please help me figure out what is going on?
How do I Compare two JSON files and form a new Custom JSON
My first JSON file(json1.json) json1 = [{ "id": 547346726, "appname": "flipkart", "sum": 120, "hours": "1 day" },{ "id": 3094923, "appname": "Amazon", "sum": 40, "hours": "2 days" }] My second JSON file(json2.json) json2 = [{ "id": 547346726, "Technology": ".Net", "deployed": "china", "Type": "Production" }, { "id": 3094923, "Technology": "scala", "deployed": "Japan", "Type": "QA" }, { "id": 123434, "Technology": "ruby", "deployed": "EU", "Type": "Business" } ] My JSON1 have two objects and my second JSON have three objects in that two objects ids are common. compare the JSON file with ids and form a new JSON. If there are no common objects id in two JSON files add the objects to Final JSON Expecting Output Final.json: finaljson = [{ "id": 547346726, "appname": "flipkart", "sum": 120, "hours": "1 day", "Technology": ".Net", "deployed": "china", "Type": "Production" }, { "id": 3094923, "appname": "Amazon", "sum": 40, "hours": "2 days", "Technology": "scala", "deployed": "Japan", "Type": "QA" }, { "id": 123434, "Technology": "ruby", "deployed": "EU", "Type": "Business" } ] so far I tried this one import json a= json.load( open("newrelics.json")) b = json.load( open("CareOrchestrator.json")) # Creating dicts by Ids. d_a = dict( [ ( x["id"], x ) for x in a ] ) d_b = dict( [ ( x["id"], x ) for x in b ] )
There's no need to create a dict. You could try something like this: import json print("Hello World") json1 = """[{ "id": 547346726, "appname": "flipkart", "sum": 120, "hours": "1 day" },{ "id": 3094923, "appname": "Amazon", "sum": 40, "hours": "2 days" }]""" json2 = """[{ "id": 547346726, "Technology": ".Net", "deployed": "china", "Type": "Production" }, { "id": 3094923, "Technology": "scala", "deployed": "Japan", "Type": "QA" }, { "id": 123434, "Technology": "ruby", "deployed": "EU", "Type": "Business" } ]""" a = json.loads(json1) b = json.loads(json2) final = [] for element in b: isThere = False for element2 in a: if element['id'] == element2["id"]: element2.update(element) final.append(element2) isThere = True if not isThere: final.append(element) json = json.dumps(final) Be aware that this solution just takes all the elements from the collection b. You won't have elements in the final result if they are just in the collection a. Therefore you'd need another loop or something like that.