<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: fhorisberger</title>
    <description>The latest articles on Forem by fhorisberger (@fhorisberger).</description>
    <link>https://forem.com/fhorisberger</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F828286%2Fe293d9fb-75ab-4bd2-a4ba-82c0e07ca58e.jpeg</url>
      <title>Forem: fhorisberger</title>
      <link>https://forem.com/fhorisberger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/fhorisberger"/>
    <language>en</language>
    <item>
      <title>Cloudfront origin failover</title>
      <dc:creator>fhorisberger</dc:creator>
      <pubDate>Sat, 16 Apr 2022 19:13:05 +0000</pubDate>
      <link>https://forem.com/aws-builders/cloudfront-origin-failover-4c9n</link>
      <guid>https://forem.com/aws-builders/cloudfront-origin-failover-4c9n</guid>
      <description>&lt;p&gt;This new article, we are speaking about CloudFront origin failover, it allows us to create a high avaliavility solutions when primary origin is unavailable.&lt;/p&gt;

&lt;p&gt;Basic view:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feom5jb6hzptk8vv4quu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feom5jb6hzptk8vv4quu8.png" alt="CloudFront Origin Failover"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't have new cloudfront distribution please visit this site:&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html" rel="noopener noreferrer"&gt;Amazon Web Site&lt;/a&gt; for creating a new distribution&lt;/p&gt;

&lt;p&gt;Then we should create an origin groups, it will be used for rerouting our request in the case that  primary origin will have a failure.&lt;/p&gt;

&lt;p&gt;An item important is CloudFront fails over to the secondary origin only when the HTTP method of the viewer request is GET, HEAD, or OPTIONS.&lt;/p&gt;

&lt;p&gt;Creating an origin group:&lt;/p&gt;

&lt;p&gt;1- Sign in to the AWS Management Console and open the CloudFront console at &lt;a href="https://console.aws.amazon.com/cloudfront/v3/home" rel="noopener noreferrer"&gt;https://console.aws.amazon.com/cloudfront/v3/home&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Choose the Origins tab.&lt;/p&gt;

&lt;p&gt;3- Make sure the distribution has more than one origin. If it doesn’t, add a second origin.&lt;/p&gt;

&lt;p&gt;4- On the Origins tab, in the Origin groups pane, choose Create origin group.&lt;/p&gt;

&lt;p&gt;5- Choose the origins for the origin group. After you add origins, use the arrows to set the priority—that is, which origin is primary and which is secondary.&lt;/p&gt;

&lt;p&gt;6- Enter a name for the origin group.&lt;/p&gt;

&lt;p&gt;7- Choose the HTTP status codes to use as failover criteria. You can choose any combination of the following status codes: 400, 403, 404, 416, 500, 502, 503, or 504. When CloudFront receives a response with one of the status codes that you specify, it fails over to the secondary origin.&lt;/p&gt;

&lt;p&gt;8- Create Origin Group&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1gs9xvdjrufogg7qstlm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1gs9xvdjrufogg7qstlm.png" alt="CreateOriginGroup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;About origin timeouts and attempts:&lt;/p&gt;

&lt;p&gt;By default, CF tries to connect to the primary origin for as long as 30 seconds (3 connection attempts of 10 seconds each) before moving to secondary origin. These values can be changed to timeouts between 1 and 10 seconds, attempts between 1 and 3 times&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awsbuilders</category>
      <category>writing</category>
    </item>
    <item>
      <title>AWS Client VPN</title>
      <dc:creator>fhorisberger</dc:creator>
      <pubDate>Wed, 16 Mar 2022 11:46:18 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-client-vpn-45j3</link>
      <guid>https://forem.com/aws-builders/aws-client-vpn-45j3</guid>
      <description>&lt;p&gt;I wrote this article for explain as connect client vpn to our aws resources using a managed client-based vpn based on OpenVPN.&lt;/p&gt;

&lt;p&gt;Details before you start to work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A vpn subnet in our vpc must be create. ( or more for High Availability)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a CIDR for Client vpn. It can't overlap with the our vpc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client CIDR ranges must have a block size between /22 and /12. It can't changed after was created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can't associate multiple subnets from the same Availability Zone with a Client VPN endpoint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optional: Aws cli installed in your workstations ( upload certificates to ACM)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's go.. &lt;/p&gt;

&lt;p&gt;In this scenario we have created the followings components: &lt;br&gt;
VPC (192.168.0.0/16): Private (192.168.0.0/24) and vpn (192.168.254.0/24) subnet. &lt;/p&gt;

&lt;p&gt;One EC2 on private subnet for testing ssh access via vpn.&lt;/p&gt;

&lt;p&gt;Two segurity-group: Inside-target-sg assigned to EC2 and VpnTarget-sg will be assigned to VPN Target Subnet on client vpn endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The followings Authentication methods are supported:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Active Directory (User-based)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mutual Authentication (certificated-based)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Single Sign-on ( SAML-based federation authentication)(user-based)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this case we use Mutual Authentication (certificated-based).&lt;/p&gt;

&lt;p&gt;we will create server and client certificates using OpenVPN easy-rsa:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone The OpenVPN easy-rsa&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/OpenVPN/easy-rsa.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd easy-rsa/easyrsa3&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialize a new PKI enviroment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./easyrsa init-pki&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To build a new certificate authority (CA)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./easyrsa build-ca nopass&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate The server certificate and key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./easyrsa build-server-full server nopass&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate the client certificate and key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;./easyrsa build-client-full clientvpn nopass&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy files to other folders&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;cp -rp pki/{ca.crt,issued/clientvpn.crt,private/clientvpn.key} /tmp/&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cp -rp pki/{issued/server.crt,private/server.key} /tmp/&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upload certicifates and keys to ACM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;aws acm import-certificate --certificate fileb://server.crt --private-key fileb://server.key --certificate-chain fileb://ca.crt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;aws acm import-certificate --certificate fileb://clientvpn.crt --private-key fileb://clientvpn.key --certificate-chain fileb://ca.crt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create AWS Client VPN EndPoint&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;you can search this section in VPC --&amp;gt; Virtual Private Network(VPN) --&amp;gt; Client Vpn Endpoints&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Name vpn endpoint: "client-vpn-endpoint"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client Ipv4 CIDR: 172.16.0.0/20&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server Certificate ARN: server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose: Use mutual Authentication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client Certificate ARN: clientvpn&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5h1luwbf175av18zjob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5h1luwbf175av18zjob.png" alt="Certificates and CIDR"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Transport Protocol: TCP&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose VPC ID: in this case 192.168.0.0/16&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Segurity Group id: (Vpntarget-sg)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qtfqipr39d6ck9l2rqu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qtfqipr39d6ck9l2rqu.png" alt="choose SG and VPCID"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VPN Port: TCP 1194. You can choose 443, too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kz3x4bpzbp5jkardsnx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kz3x4bpzbp5jkardsnx.png" alt="Choose port number"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Associate target subnet &amp;amp; Authorize Traffic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this section, we select the client vpn endpoint created earlier for adding an authorization rule.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Associate Subnet Target Network (192.168.254.0/24)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fma91fpzp7u8uchiyguuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fma91fpzp7u8uchiyguuy.png" alt="Subnet target network "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rules to grant clients access to the networks. In this case we choose 192.168.0.0/16 that is our vpc but we would choose 0.0.0./0 for sending traffic to internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5hg2d7kmjuuewxlb0lu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5hg2d7kmjuuewxlb0lu.png" alt="Authorization Rule"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Last step: Download and update VPN configuration file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if you need OpenVPN client. It can be download in:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://openvpn.net/community-downloads" rel="noopener noreferrer"&gt;https://openvpn.net/community-downloads&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Select Client VPN Endpoint and "Download Client configuration" to your local workstation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download or copy the client certificate ( clienvpn.crt, clientvpn.key)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open this configuration File and add following lines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cert /path/clientvpn.crt&lt;/li&gt;
&lt;li&gt;key /path/clientvpn.key&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Import file from OpenVpn Client&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Connect and  Enjoy :D&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Monitoring Client Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can monitor all our client connections from the console for a quick real-time view of our client connections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzvrkfb3biju5wgx8ih12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzvrkfb3biju5wgx8ih12.png" alt="Monitoring Connection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This vpn connection is a way easy, secure and fast for connecting us to our resources on AWS or on-premise DataCenter.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
