How to display nested related model data in Ember - ember.js

To preface this, I'm new to Ember and using Mirage to mock a JSON-API compliant backend, but I've hit a snag on what I think would be a common scenario. Ideally, I'm looking to create a single view that lists posts and the comments for each post underneath. The trouble comes when I want to display the author associated with each comment. So, I must clearly be doing something wrong here, since Ember knows how to fetch the direct associations for the Post model, but anything deeper than that is undefined.
In my route, I fetch all posts and that knows to then request the relationship data from the proper Mirage routes.
// app/routes/index.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('post');
}
});
This is the response that Ember receives from Mirage when requesting all posts.
{
"data": [
{
"type": "posts",
"id": "1",
"attributes": {
"title": "Vero quas non inventore eos vel rerum nesciunt nemo molestiae.",
"body": "Eum minima beatae ullam nam id ut quia.\nPorro quidem blanditiis provident qui ex voluptas temporibus officia quos.\nDeleniti aut soluta placeat illo.\nId aut dolorem illo fugit corrupti commodi.\nPorro nesciunt enim debitis.\nMinima architecto velit corporis excepturi eos qui.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "10"
}
},
"comments": {
"data": []
}
}
},
{
"type": "posts",
"id": "2",
"attributes": {
"title": "Id quae est omnis dolorum quaerat aut sed corrupti voluptatem.",
"body": "Est ipsa voluptas quia quae nihil ipsum assumenda itaque nihil.\nTotam aut quia.\nRerum maxime cum distinctio harum dolorem dolores dicta.\nNesciunt id et minima velit omnis eius itaque ad.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "1"
}
},
"comments": {
"data": []
}
}
},
{
"type": "posts",
"id": "3",
"attributes": {
"title": "Provident et eius est.",
"body": "Neque autem deserunt.\nAb repellendus nemo et aut sunt veritatis facere asperiores soluta.\nEt placeat id dicta sint.\nHarum temporibus eos labore.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "8"
}
},
"comments": {
"data": []
}
}
},
{
"type": "posts",
"id": "4",
"attributes": {
"title": "A similique explicabo itaque dolor vel possimus aut praesentium veritatis.",
"body": "Inventore et ipsum ut porro.\nUt sed est unde illo nulla id doloribus accusamus voluptatum.\nTempora officiis ut enim porro et est qui.\nSit qui minima iste eaque cupiditate molestiae ut omnis magni.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "4"
}
},
"comments": {
"data": []
}
}
},
{
"type": "posts",
"id": "5",
"attributes": {
"title": "Et in consequatur ut autem et.",
"body": "Qui voluptatem harum aut amet possimus architecto eos commodi.\nNumquam cupiditate fugit.\nQuod consequatur minima aspernatur nobis qui eligendi qui corporis necessitatibus.\nIste velit perferendis non dolore ipsum perspiciatis quia.\nAut delectus et porro cupiditate laboriosam dolorem.\nEaque ipsa rerum ipsam placeat voluptatem enim.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "1"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "4"
}
]
}
}
},
{
"type": "posts",
"id": "6",
"attributes": {
"title": "Exercitationem quo perferendis.",
"body": "Dolor ut voluptates placeat ullam.\nOmnis aut et.\nIste est tenetur deleniti ea incidunt eos voluptas veniam iusto.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "3"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "1"
},
{
"type": "comments",
"id": "5"
},
{
"type": "comments",
"id": "9"
}
]
}
}
},
{
"type": "posts",
"id": "7",
"attributes": {
"title": "Officia ea quod natus corrupti.",
"body": "Et quia qui occaecati aspernatur voluptatem error in.\nDoloremque rerum sed autem minima quidem reiciendis.\nPossimus dolores voluptas voluptate rerum veniam dicta.\nNemo dolore perspiciatis harum dolorem soluta ab consectetur animi sed.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "1"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "3"
}
]
}
}
},
{
"type": "posts",
"id": "8",
"attributes": {
"title": "Quia ea cum vel repudiandae.",
"body": "Excepturi dolores sed modi est asperiores deleniti.\nTempore architecto recusandae nostrum culpa expedita iure voluptatibus accusantium nemo.\nQuia est voluptatum nulla earum culpa.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "7"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "2"
},
{
"type": "comments",
"id": "7"
},
{
"type": "comments",
"id": "8"
}
]
}
}
},
{
"type": "posts",
"id": "9",
"attributes": {
"title": "Nam fugit in voluptatibus et.",
"body": "Aut nihil atque tempore beatae voluptas.\nOptio voluptatum qui debitis omnis dolor maiores cumque.\nUt dolorem est magnam eveniet.\nMagni porro occaecati ex autem.\nPorro et alias beatae nemo laboriosam ut sint magnam quis.\nMollitia deserunt culpa non.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "9"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "10"
}
]
}
}
},
{
"type": "posts",
"id": "10",
"attributes": {
"title": "Aut delectus nobis voluptate.",
"body": "Alias impedit itaque at rerum enim.\nVoluptas itaque quaerat qui optio quo.\nNihil voluptatem quos nihil pariatur sapiente tempore necessitatibus quia et.\nSed consectetur modi dolorum sunt ex odit at.\nVoluptas numquam totam dolores ipsam rerum.\nEt hic eum sunt et.",
},
"relationships": {
"author": {
"data": {
"type": "users",
"id": "1"
}
},
"comments": {
"data": [
{
"type": "comments",
"id": "6"
}
]
}
}
}
]
}
After getting all posts and the top-level relation models, Ember doesn't go any deeper so I'm left with an undefined comment.author in my template. Is there some way I can tell Ember to fetch the nested models that I need or am I going about this all wrong?
EDIT
This is the structure of my models and the templates for them. Hopefully, it will help give some more context.
Post model:
// app/models/post.js
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr('string'),
body: DS.attr('string'),
createdAt: DS.attr('date', {
defaultValue() { return new Date(); }
}),
author: DS.belongsTo('user'),
comments: DS.hasMany('comment')
});
Comment model:
// app/models/comment.js
import DS from 'ember-data';
export default DS.Model.extend({
body: DS.attr('string'),
createdAt: DS.attr('data', {
defaultValue() { return new Date(); }
}),
author: DS.belongsTo('user'),
post: DS.belongsTo('post')
});
User model:
// app/models/user.js
import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
posts: DS.hasMany('post'),
comments: DS.hasMany('comment'),
fullName: Ember.computed('firstName', 'lastName', function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
})
});
Index template:
// app/templates/index.hbs
{{#each model as |post|}}
{{post-content post=post}}
{{/each}}
Post template:
// app/templates/components/post-content.hbs
<div class="post-main">
<h5 class="post-author-name">{{post.author.fullName}}</h5>
<div class="post-timestamp">
<h5 class="time-in-words">{{moment-from-now post.createdAt interval=1000}}</h5>
</div>
<div class="post-content">
<h2 class="post-title">{{post.title}}</h2>
<p class="post-body">{{post.body}}</p>
</div>
<div class="post-actions">
<h6>Comments ({{post.comments.length}})</h6>
</div>
</div>
<ul class="post-comments">
{{#each post.comments as |comment|}}
{{post-comment comment=comment}}
{{/each}}
</ul>
Comment template:
// app/templates/components/post-comment.hbs
<!-- This is blank -->
<h5>{{comment.author.fullName}}</h5>
<!-- This is not blank -->
<p>{{comment.body}}</p>

Related

"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.

MapFish:print Styling not applying

I'm trying to build a MapFish Style that i can apply to mixed Well known text types
example feature
{
"geometry": {
"type": "LineString",
"coordinates": [...],
"properties": {
"Name": "KN",
"id": "5a002a8e9ee4e84a3c125067",
"geoType": "LineString",
...
},
"profile":{...}
"type": "Feature"
},
and i am applying this style
{
"version": "2",
"[geoType IN ('LineString', 'MultiLineString', 'Curve', 'MultiCurve', 'CompoundCurve')]": {
"symbolizers": [{
"type": "Line",
"strokeColor": "#000080",
"strokeOpacity": "0.65",
"strokeWidth": "5.0"
}]
},
"[geoType IN ('Polygon', 'MultiPolygon', 'Triangle', 'CircularString', 'CurvePolygon')]": {
"symbolizers": [{
"type": "Line",
"strokeColor": "#000080",
"strokeOpacity": "0.65",
"strokeWidth": "5.0"
}, {
"type": "polygon",
"strokeColor": "#000080",
"strokeOpacity": "0.65",
"strokeWidth": "5.0",
"fillColor": "#000080",
"fillOpacity": "0.65"
}]
},
"[geoType IN ('Point', 'MultiPoint')]": {
"symbolizers": [{
"type": "point",
"pointRadius": "20",
"graphicName": "circle",
"graphicWidth": "20",
"strokeColor": "#000080",
"strokeOpacity": "0.65",
"strokeWidth": "5.0",
"fillColor": "#000080",
"fillOpacity": "0.65"
}]
}
}
it is throwing no error and the print completed but when i get nothing from the GeoJSON
any pointers on what I've got wrong?
The issue is the Profile attribute, not sure why but if your GeoJson has any extra properties in the root of the node mapfish wont process it

Chart.js 2.x: labels displaying over eachother

The last two labels display over each other as shown in the image below. How do I fix this?
Here's some lorem ipsum so stackoverflow doesn't complain about my post being mostly code: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra porta pretium. Suspendisse vitae congue turpis, eu condimentum turpis. Cras a ultrices velit. Sed semper efficitur felis, et porttitor sapien vestibulum ac. Sed viverra porttitor arcu, ac finibus ligula ultrices non. Nullam quis porttitor elit. Maecenas fringilla erat sed libero luctus efficitur vel sit amet massa. Proin hendrerit metus in nibh fringilla malesuada. Proin turpis turpis, tempor non venenatis eu, fringilla in nunc. Proin ultricies neque sit amet nisi posuere sagittis. Vivamus erat massa, hendrerit nec nibh vitae, commodo faucibus felis. Maecenas a urna diam.
Options:
var options = {
scales: {
xAxes: [{
gridLines:{
display:false,
},
type:"time"
}],
yAxes: [{
ticks:{
stepSize:10000
}
}]
}
};
Data:
{
label: "My Dataset",
fill: false,
lineTension: 0.1,
borderColor: "#8CCEC2",
backgroundColor: "#8CCEC2",
borderCapStyle: 'butt',
borderJoinStyle: 'miter',
pointRadius:0,
data: [
{
x:moment((new Date()).toISOString()).subtract(1,"days")
,y:9000
},
{
x:moment((new Date()).toISOString()).subtract(2,"days")
,y:11000
},
{
x:moment((new Date()).toISOString()).subtract(3,"days")
,y:8000
},
{
x:moment((new Date()).toISOString()).subtract(4, "days")
,y:10000
},
{
x:moment((new Date()).toISOString()).subtract(5, "days")
,y:9000
}
],
spanGaps: false
}
Unfortunately, chart.js has trouble sometimes auto-fitting a time scale x-axis because of all the format variations and possibilities. You can do one of two things to solve this. Either expand the size of the chart container (so that there is more room to render the chart) or configure the time scale manually to optimize how it looks.
In this specific case I used the time.unit property to display the scale in units of 'days'. Here is the relevant config:
scales: {
xAxes: [{
gridLines: {
display: false,
},
type: "time",
time: {
unit: 'day',
}
}],
yAxes: [{
ticks:{
stepSize: 10000
}
}]
}
Here is a codepen to demonstrate what I mean.
Try scales.xAxes[0].time.round = 'day'
This fixed it for me.
before:
after:
e.g.,
scales: {
xAxes: [{
type: "time",
time: {
format: "MM/DD/YYYY",
round: 'day',
tooltipFormat: 'll'
},
scaleLabel: {
display: true,
}
}],
}

Swift: Can't seem to access objects in nested array

I am testing my feet in Swift and am trying to access certain objects which are part of a nested array.
The structure of the array looks something like this:
[ "Title": "Book Title", "Type": "Fiction", "Chapters": [
{"Title": "Chapter 1 Title", "Content": "Lorem ipsum dolor sit amet...", "Keyword": "foo"},
{"Title": "Chapter 3 Title", "Content": "Lorem ipsum dolor sit amet...", "Keyword": "foo"},
{"Title": "Chapter 5 Title", "Content": "Lorem ipsum dolor sit amet...", "Keyword": "foo"},
...
],
[ "Title": "Book Title", "Type": "Fiction", "Chapters": [
{"Title": "Chapter 2 Title", "Content": "Lorem ipsum dolor sit amet...", "Keyword": "foo"},
{"Title": "Chapter 3 Title", "Content": "Lorem ipsum dolor sit amet...", "Keyword": "foo"}
],
...]
The array is loaded from a plist file and is loaded something like this:
var myArr: Array<Any>
myArr = NSArray(contentsOfFile: path!) as! [Dictionary<String, Any>]
I am having difficulty accessing specific children of the chapters array.
let bookNum = 1
let chapNum = 3
let s: Dictionary = myArr[bookNum] as! Dictionary<String, Any>
if let s1 = (s["Chapters"] as AnyObject)[chapNum] {
if let obj = s1 as! Dictionary<String, Any> {
print("/(obj["Title"])")
}
}
I get the error, that "Initializer for conditional binding must have optional type, not Dictionary".
In general I am getting the feeling that I am not doing this correctly. The problem is, that the exact structure of the array is not known. Theoretically a Book could be listed without chapters.
Thanks for help in advance.
You have already specified the myArr type as [Dictionary<String, Any>], so there is no need to explicitly specify the type of s because if you access object from myArr it should only dictionary nothing else.
let s = myArr[bookNum]
Now Chapters is also Array of dictionary so you need to type cast it that and then access the chapter according to you want.
if let chapters = s["Chapters"] as? [Dictionary<String, Any>] {// OR [[String:Any]]
if chapNum < chapters.count {
print(chapters[chapNum]["Title"])
}
}

Where are AWS EC2 Availability Zones exactly?

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