Skip to content

Instantly share code, notes, and snippets.

@hibri
Created October 5, 2022 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hibri/feea23d9101049b25f968ab6786ec66f to your computer and use it in GitHub Desktop.
Save hibri/feea23d9101049b25f968ab6786ec66f to your computer and use it in GitHub Desktop.
First pass at using cdk tf
class Program
{
public static void Main(string[] args)
{
App app = new App();
MyStack stack = new MyStack(app, "datafactory");
new LocalBackend(stack);
app.Synth();
}
}
public class MyStack : TerraformStack
{
public MyStack(Construct scope, string id) : base(scope, id)
{
var azurermProviderConfig = new AzurermProviderConfig() { Features = new AzurermProviderFeatures() };
var azurermProvider = new AzurermProvider(this, "AzureRm", azurermProviderConfig);
ResourceGroup rg = new ResourceGroup(this, "hibri-test", new ResourceGroupConfig
{
Location = "uksouth",
Name = "hibri-test"
});
var storageAccountConfig = new StorageAccountConfig
{
Name = "hibrifuncstr",
ResourceGroupName = rg.Name,
Location = rg.Location,
AccountReplicationType = "LRS",
AccountTier = "Standard"
};
var functionStorageAccount = new StorageAccount(this, "hibrifuncstr", storageAccountConfig);
var appServicePlanConfig = new ServicePlanConfig
{
Name = "test-plan",
ResourceGroupName = rg.Name,
Location = rg.Location,
OsType = "Linux",
SkuName = "B1"
};
var appServicePlan = new ServicePlan(this, "test-plan", appServicePlanConfig);
var functionAppConfig = new LinuxFunctionAppConfig
{
Name = "hibrifuncapp",
ResourceGroupName = rg.Name,
Location = rg.Location,
ServicePlanId = appServicePlan.Id,
AppSettings = new Dictionary<string, string>(),
StorageAccountName = functionStorageAccount.Name,
StorageAccountAccessKey = functionStorageAccount.SecondaryAccessKey,
SiteConfig = new LinuxFunctionAppSiteConfig
{
ApplicationStack = new LinuxFunctionAppSiteConfigApplicationStack
{
DotnetVersion = "6.0"
}
}
};
var functionApp = new LinuxFunctionApp(this, "functionapp", functionAppConfig);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment