Posts

aws ec2 instance - how to scale up

Image
 You can scale up your AWS EC instance by, going into Instance -> Instance Settings-> Change Instance type - as shown below :-

aws connecting to your ec2 instances via ssh

To connect the ec2 instances, is pretty straight forward, just run ssh -i <your-key-pair-file-name>.pem and then follow by username@your-public-ec2-instance name.  However, sometime we tend to forget about the default username and spend time looking for this info. This is documented here:- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect.html#connection-prereqs-get-info-about-instance    

Windows SSH: Permissions for 'private-key' are too open

Image
Due to a security permission constraints on your folder,  when using ssh via pem file, it needs to be secured. To do what, place your file in a folder and then configure the necessary permission.  right click on the folder, right click on properties -> security -> Advance tab (as shown in figure below). Once you click on Apply, try to re-connect again.

curl how to switch between ipv4 and ipv6 mode

You can use curl -4 icanhazip.com to use ipv4 and  curl -6 icanhazip.com .

Setting up diagnostic logs workspace to push to an event hub

 Generally setting this up is pretty straight forward, i can use az powershell command to do it.  New-AzDiagnosticSetting -Name testsetting -ResourceId < your-resource-id > -Log $log -Metric $metric -EventHubName ehname -EventHubAuthorizationRuleId < your-RootManageSharedAccessKey-auth-rule-id > The thing that i got tripped alot here is the rule id. Given that i have a separate rule id for event hub called eh-test, it wouldn't work. It will give me an error saying "invalid auth id" - which leads me to think there's something wrong with my auth id value or perhaps permission. I have tried setting read, write and manage permission yet the outcome is still the same. Instead i have to resort to using root managed rule id. 

ubuntu - running python using python instead of python3

 Can be really annoying trying to convert scripts or code to run python3 instead of just python from the command line. Of course there's alias command that you can use.  Thankfully we have this package here.  apt install python-is-python3

kubectl create a pod with dry-run

 You can use the following command to generate a yaml file to create a pod easily  kubectl run mypod --restart=Never --image=nginx--dry-run=client -o yaml

installing mssql-cli on Linux via pip

  To install mssql-cli in linux, the microsoft guide to add package and apt-get install mssql-cli doesn't work.  So have to resort to using pip to setup this guy. apt-get update apt-get install -y python3-pip apt-get install -y python-is-python3 Installing MSSQL-Cli To install mssql-cli, run the following command:- pip install mssql-cli

hotchoc setting up banana cakepop apikey

Image
  Open up banana cakepop and then proceed to sign in to your account. Create one if you don't have one. Choose your identity provider.   Click on Document or the page icon (just below the Cakepop icon) to open up a document. Then go slightly right, and create "New API Key" (as shown in the green arrow below).  For the API type you can select API Service, I will select API Service. You can change to other API type later.  Then configure your service, I will just enter "http://localhost:5098/" for schema endpoint and click "Apply". In the Finish section click on Save. Goto stages, and click on "Use default setup", Next, goto the Overview tab and you should be able to get your API ID. 

hotchoc fusion demo - getting started guide

Image
To get started with HotChoc fusion   Clone this repository here  https://github.com/mitzenjeremywoo/fusion-demo/tree/main Run the command in the README.md. If you are running in linux, then build.sh would work fine. Otherwise run the command from the fusion-demo root directory.  Run one of the services, lets say account -  dotnet run --project Accounts Then run dotnet run --project Gateway To go http://localhost:5098/graphql/ and run the following command:-  query {   users {     nodes {       id       name     }   } } You should be able to get an outputs shown below:

Your BananaCakePop.Services configuration is invalid. `ApiId` is required and was not set!

  I am getting an error from running sample demo for Hotchoc fusion. It is just missing banana cakepop configurations.  Configure your services by using the following code snippet. You can have your own ApiId, ApiKey and stage but you have to do the required setup.  The following ApiId, ApiKey and Stage are copied from the docs - it is not really mine.  builder.Services     .AddFusionGatewayServer ()     .ConfigureFromCloud ()     .CoreBuilder     .AddInstrumentation(o = > o.RenameRootActivity = true )     .AddBananaCakePopServices(x = >     {         x.ApiId = "VGhpcyBpcyBub3QgYSByZWFsIGFwaSBpZA==" ;         x.ApiKey = "Tm9wZSwgdGhpcyBpcyBhbHNvIG5vIHJlYWwga2V5IDspIA==" ;         x.Stage = "dev" ;     });

a quick link to get vikingcloud and securetrust cert for validation purposes

This is the link to get your vikingcloud and securetrust certs.   https://certs.securetrust.com/ support/support-root-download. php

aws s3 policy setting

  trying to set AWS S3 policy and i would have thought if i were to set it directly in the s3 bucket itself, i won't have to add a resource. Boy was i wrong. This policy was the one that works, after so many time messing around with it. So the principal must be valid ARN. The resource too must be a legit ARN resource.  In this example, i am denying user from uploading. Even though this user is configure to have ALL s3 permission by default, having this policy blocks the principal from uploading to this bucket. {     "Version" : "2012-10-17" ,     "Statement" : [         {             "Sid" : "PolicyForDenyUploadWithACL" ,             "Effect" : "Deny" ,             "Principal" : {                 "AWS" : "must-be-a-valid-arn-pricipal"             },         ...

EC2 instance my quickstart of setting up web server

  When setting up EC2 instance, these bad boys are really good for setting up http server by placing it in the user data sections.   sudo yum update -y sudo yum install -y httpd sudo systemctl start httpd sudo systemctl enable httpd sudo cat "<h1>hello there! </h1>" > /var/www/html/index.html

aws route 53 creating alias to a s3 bucket static website

Image
  Go to  Route 53 . Go to hosted zone and create one if you don't have one.  Then click on create record, provide a name. For the record type choose "A". Then ensure you click on Alias. The list of traffic endpoint will appear as shown below:- Select your s3 webstatic and click on "Create record". Reference  https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RoutingToS3Bucket.html

Permission denied inside /var/www/html when creating a file

 Trying to configure my ec2 instance and then bump into this issue. Thanks for stack overflow, all i need to do is this below sudo chown - R $ USER :$ USER / var / www Setting up web server. Note: there's a difference between where you put the -y options. In my case, it has to be yum install -y and not yum install httpd -y sudo yum update -y sudo yum install httpd –y sudo systemctl start httpd sudo systemctl enable httpd sudo cat "<h1>hello there! </h1>" > /var/www/html/index.html

elastic beanstalk configuring your application load balancer type

Image
  AWS beanstalk allows us to configure the load balancer type but you need to choose "high availability" or custom presets instead of using the default configuration. Then in the " Configure instance traffic and scaling " section you can configure the load balancer - as shown below:

error NU1900: Warning As Error: Error occurred while getting package vulnerability

 Getting a package vulnerability while trying to build a c# application.  The ideal solution would be to update your package in your project. However, there's a workaround there by you can turn nuget auditting off - as shown below with <NugetAudit> block <PropertyGroup>     <TargetFramework>net6.0</ TargetFramework>     <ImplicitUsings>enable</ ImplicitUsings>     <Nullable>enable</Nullable> <TreatWarningsAsErrors>True</ TreatWarningsAsErrors> <WarningsNotAsErrors></ WarningsNotAsErrors> <NuGetAudit>false</NuGetAudit> <NoWarn></NoWarn>   </PropertyGroup> Here is a link that you can get some additional resources  https://learn.microsoft.com/ en-us/nuget/concepts/auditing- packages#disabling-security- auditing