How to implement AWS Cognito (ionic) - amazon-web-services

I am trying to implement AWS cognito service into my app (ionic 2/3), from scratch. I have no previous experience with AWS.
I did make work the ionic2-starter-aws project (even if the tutorial was missing a lot of things) but since I was importing a project into the mobile hub, I did not learn anything useful for my App.
What I did:
Made my app work without any AWS service.
Created a mobile hub, added a user pool (User Sign-in)
Activated Hosting And Streaming (from the Mobile Hub) and downloaded aws-config.js
Copy/pasted providers files from https://github.com/ionic-team/ionic2-starter-aws /src/providers/ (they were made for aws connection, no point in re-writing them I guess)
Here I tried adding aws-config.js different way (into src/assets, same place than index.html, at the project root, ...) without success, all I get is AWSCognito is not defined. This error laid almost no result so I guess I forgot/did something wrong at some point (I am guessing it come from declare var AWSCognito: any; inside aws.cognito.ts but it wasn't declared before, but why does it work with ionic2-starter-aws then ?)
What are the steps to implement Cognito ? Lots have been made for javascript but they doesn't seem to work for typescript ?

Related

Terraform UI for non technical CLI users?

I currently have a server build process that uses Terraform and deploys a server all from code.
I'm looking for a web UI with forms that I could either populate specific fields and or do API get commands against a VCenter or wherever the server is being built to populate the specific fields. The fields that get populated would be stored as the variables.tf file and when someone hits submit, it would run the actual Terraform command terraform apply to build the server based on the variables. My guess is the terraform binaries would have to live on there so it could run in the background.
It doesn't have to be some super fancy web page, just something that I could potentially make look cool for Director level folks.
Also, I don't want to use TF enterprise, yet. I've looked into a couple of open source projects (atlantis and terrahub) but none seem to be what I'm looking for.
I'm far from a web developer so any help would be awesome.
You can try with SLD
Stack-Lifecycle-Deployment
I think it has everything that you need
It is very intuitive, it has a web interface and a rest api to easily integrate it with the rest of the applications.

Chrome hitting my Django backend but I only made an iOS app

So I have a Django backend deployed on Google App Engine. This backend supports an iOS app. In my server logs I can see all the requests coming in and where they were made. It used to be that I would only get requests from Joon/7.** (which is the iOS app name + version). However, recently I've been getting requests from Chrome 72 which doesn't make sense cause the app shouldn't be able to be used on Chrome. Furthermore these requests are creating a lot of errors in my backend because it is not sending an authentication token. Does anyone know what is going on here? Are my servers being hacked?
Looks like someone discovered the URL to your App Engine app. You can use Ingress controls to only allow access via Cloud Load Balancing and then Google Cloud Armor in front to protect that with rules that look like:
has(request.headers['user-agent']) && request.headers['user-agent'].contains('Godzilla')
It is quite common to see all sorts of hits (from what I call spam bots) to an App Engine App. Technically, GCP expects you to use Google Firewall rules to block these. The challenge though is that these bots usually change their IP Addresses frequently or use multiple ones. I don't have a 'perfect' solution.
a) You can try the method by #jeff-williams (I've never tried that)
b) You can also try GCP's firewall rules (I use this but I try to block a range of IPs instead of blocking them one by one)
c) Sometimes I also put my service behind a specific non-intuitive path. This way, the spam bots will only hit the default/base url and then I have a separate service which returns 404 for all calls to that base url

Building a multi page serverless application using AWS Lambdas Serverless application model

I am new to the serverless application model for the web and want to understand a few things. I went through the AWS Building your first serverless tutorial and have a couple of questions. I am used to the MVC model of LEMP or using .NET.
In the tutorial all the pages that were accessed were static html like app.com/login.html and app.com/ride.html. Is this the way things are done in the serverless world? I get it that the lamdba and rest api add the dynamic content.
How do I name the pages in my browser to go from app.com/ride.html to app.com/ride-to-london instead?
Is Lamdba essentially like just writing Node.js?
Is there a way if they are all individual html pages to make one global layout? Any layout template advice would be helpful.
I want a multi page application like say this site vs Gmail (less ajaxy) and more like a blog. How is this accomplished? A tutorial on this would be helfpul.
Thanks.
1) you can use a modern front end framework like Angular, React, Vue, etc. and host your website statically on S3. Check
Hosting a Static Website on Amazon S3 for more info. Your static website will then interact via HTTP with API Gateway. You then map your lambda functions to events from API Gateway. Check this tutorial
2) depends on how the framework chosen on step 1) deals with it
3) it can be NodeJS, Go, Python and other supported languages if you wish. Each microservice (lambda function) can be written in a separate language. For more info, see the supported languages at
Lambda FAQ
4) again, depends on the framework of your choice
5) this you’ll have to lookup for yourself, but anything like "Blog Tutorial in {Framework of Choice} should do it. Here's an example using React
Let's now say you have deployed your application, you can then make use of other Events supported by AWS. Since you're creating a Blog example, you may want to upload pictures to your Post itself so it looks fancy, but you don't want users on mobile phones to load these high resolution pictures when they are only browsing through your Blog, so you could make use of an S3 Event to generate a thumbnail for your picture, so they can have a preview before actually clicking to see the content. The possibilities are endless.
Using a Serverless model to create applications also enables building event-driven applications out of the box. These applications are highly available and auto-scalable by default.

Azure Resource Template for new api app resource

I want to create an Azure Resource Group template which includes the new api app resource. I say new since api apps have changed: App Service API Apps - What's changed
.
I tried this Create a Logic App plus API app using a template . Note: I don't want to create a logic app but this example also includes an api app. When I run this example I get a message: There is a new version of API Apps. Click here to learn more. So this is not the correct example. I can't find a better example.
Note: when I simply add "kind: apiapp" to the "Microsoft.Web/sites" resource, no apiapp is deployed, I also don't get an error.
So my question is how to create a new api with Azure Resource Templates.
I contacted MS for this, they helped me and now it's fixed. Their answer:
Have you installed the new Azure SDK version 2.8.2.1? In that release (actually in 2.8.1 and beyond) we added “Export ARM Template” capability to the provisioning UI. So when you go to publish, then click the New button, you can export your ARM template. That way you’d be able to see exactly the right syntax for creating an API App.
So in VS create a web application, publish it to app service, check api app and then click the export button and you get the correct json.
See also:
https://feedback.azure.com/forums/223579-azure-portal/suggestions/7163577-ability-to-export-a-resource-group-as-a-template

Run hubot as a part of express app

I have a pretty standard express app, built using the express-generator. Now, I would like to automate some of the things in the app with hubot and I have managed to successfully perform testing and run hubot with slack adapter. However, I would like to have the bot be a part of a regular app.
How can I change the structure of the app (I have a pretty standard import of routes.js which has all of the routes for the app) to allow for the two to run together?
This is running on azure as a WebApp and I have set up a continuous integration with GitHub, so I pretty much just push code and it gets deployed, I don't run anything manually on the actual server. I would be able to run the hubot and server it on a different subdomain or path on the app if it was a regular VPS, but since the azure is taking care of those things, I would need the hubot somehow baked-in the actual express app.
As I know, Hubot has a build-in express web framework that can serve HTTP requests. So theoretically you can integrate hubot with your express webapp thru the router dispatch different urls between express app and hubot.
As references, there is a experimental package project hubot-express shows that hubot as a express app startup. you can try to refer to the code https://github.com/hubot-scripts/hubot-express/blob/master/src/hubot-express.coffee to implement the integration.
The key code: robot.express = app = express();
And the article "Automation and Monitoring with Hubot" show the code that how to serving http requests, please move to https://leanpub.com/automation-and-monitoring-with-hubot/read#leanpub-auto-serving-http-requests to review it.
The key code: robot.router.post('/hubot/notify/:room', function(req, res) {...});
To add to this, in the end I moved to botkit library that provides way easier and integrated way to have both the server and the actual app.