Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cloud Infrastructure as F#

Cloud Infrastructure as F#

Modern cloud applications consist of many moving parts, so they are hard to manage without employing Infrastructure-as-Code approach.

Traditionally, tools like CloudFormation, ARM templates and Terraform employ text-based templates, which tend to be tedious, repetitive and difficult to reuse.

What if instead of configuration files you could just use F#? See how to bring types, components, and much more to your cloud infrastructure definition.

Mikhail Shilkov

April 04, 2019
Tweet

More Decks by Mikhail Shilkov

Other Decks in Programming

Transcript

  1. Azure Function code type Item = { id: string, url:

    string } [<FunctionName("Navigate")>] let Navigate( [<HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "{id}")>] req: HttpRequestMessage, [<CosmosDB("mydb", "myitems", Id = "{id}", ConnectionStringSetting = "CosmosDBConnection")>] doc: Item) = if box doc <> null then RedirectResult doc.url :> IActionResult else NotFoundResult () :> IActionResult
  2. Azure Function code type Item = { id: string, url:

    string } [<FunctionName("Navigate")>] let Navigate( [<HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "{id}")>] req: HttpRequestMessage, [<CosmosDB("mydb", "myitems", Id = "{id}", ConnectionStringSetting = "CosmosDBConnection")>] doc: Item) = if box doc <> null then RedirectResult doc.url :> IActionResult else NotFoundResult () :> IActionResult
  3. ARM Templates: "resources": [ { "type": "config", "name": "appsettings", "apiVersion":

    "2015-08-01", "properties": { "Project": "functionApp", "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]", "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]", "WEBSITE_CONTENTSHARE": "[toLower(parameters('siteName'))]", "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('microsoft.insights/components/', parameters('siteName')), '2015-05-01').InstrumentationKey]", "SHORTENER_URL": "[toLower(variables('shortenerUrl'))]", "UTM_SOURCE": "[toLower(parameters('utmSource'))]", "FALLBACK_URL": "[toLower(parameters('fallbackUrl'))]", "FUNCTIONS_EXTENSION_VERSION": "~1", "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0", "ROUTING_EXTENSION_VERSION": "~0.2" },
  4. How Pulumi works 17 CLI and Engine Last deployed state

    Program.fs Language host AWS Azure GCP Kubernetes new Resource() Create, update, delete
  5. Slides: https://speakerdeck.com/mikhailshilkov/cloud- infrastructure-as-f-number Pulumi: https://pulumi.io/ Multi-Language in Pulumi: https://github.com/pulumi/pulumi/issues/2430 My

    article on Why Pulumi: https://mikhail.io/2019/02/from-yaml-to- typescript-developers-view-on-cloud- automation/ Useful Links