Placing repository inside subdirectory in Databricks Repos with Terraform - terraform

With Terraform I am trying to create a directory inside Repos, with a repository.
resource "databricks_directory" "test_directory" {
path = "/Repos/test123"
}
resource "databricks_repo" "test_repo" {
url = "https://somegiturl.com"
path = databricks_directory.test_directory.path
# Other variations tried:
#2 path = "/Repos/test123"
#3 path = "${databricks_directory.test_directory.path}/"
#4 path = "/test123"
branch = "main"
}
The first resource successfully creates the test123 folder inside Repos.
The second resource states for path option 1, 2 and 3:
Error: Invalid repo path specified
Option 4:
Error: Repos can only be created in the /Repos folder
Apparently I am missing something... How can I successfully place the repository inside the test123 folder?

Okay, so apparently you need to put the repo as a folder inside the directory.
So it should be:
path = "/Repos/test123/MyRepo"
or
path = "${databricks_directory.test_directory.path}/MyRepo"

Related

Terraform file path is not being resolved when using {path.cwd}

I have been trying to fix what seems to be a path resolving issue while running Terraform. The issue I notice is, the ${path.cwd} is resolving to /terraform path and not the actual path in which the .tf files and the output.tf files exist. I have tried hardcoding the path, but, what I see error related to the file not being available in that path as well. How to list out all the files in path.cwd to help with debugging if it is possible? What could be causing this?
output {
value = templatefile {
"${path.cwd}/somefile.yml" {
x = a.b.c.something.id,
y = c.v.b.something.id
}
}
}

Terraform, Archive failed due to missing directory

I have been working on Terraform using AzureDevOps before that I developed tf files using VS code and everything worked fine when try to move files from VS code to Azure DevOps , getting issue on Archive source file path it unable to find the directory, searched every where but unable to resolve this,
Path which was working fine on VS code was “…/Folder name” using same path in Azure DevOps as I have upload completed folder that I have build in VS code but it always get failed when try to archive files as it un-able to find the directory.
[Code Block DevOps]
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
# Root module should specify the maximum provider version
# The ~> operator is a convenient shorthand for allowing only patch releases within a specific minor release.
version = "~>2.11"
}
}
}
provider "azurerm" {
features {}
#skip_provider_registration = true
}
locals {
location = "uksouth"
}
data "archive_file" "file_function_app" {
type = "zip"
source_dir = "../BlobToBlobTransferPackage"
output_path = "blobtoblobtransfer-app.zip"
}
module "windows_consumption" {
source = "./modules/fa"
archive_file = data.archive_file.file_function_app
}
output "windows_consumption_hostname" {
value = module.windows_consumption.function_app_default_hostname
}
Image of VS Code where everything is working fine:
Image of DevOps where getting Missing Directory Error:
Folder Structure that is working fine with VS code
It was due to path which is fixed now,

Referencing Lambda Source Files in Sibling Directory using Terraform

I am attempting to deploy a Lambda function using Terraform, where my source files are in a different directory adjacent to where I have my Terraform files. I want to have Terraform do the zipping of the source files for me and deploy them into the Lambda. Terraform doesn't seem to want to recognize that my files are there, though.
My directory structure:
project_root/
deployment/
terraform/
my-terraform.tf
function_source/
function.py
I want it to package everything in function_source directory (there is only one file there now, but may be more later) and drop it into the deployment directory.
My Terraform:
data "archive_file" "lambda_zip" {
type = "zip"
output_path = "../function.zip"
source_dir = "../../function_source/"
}
resource "aws_lambda_function" "my_lambda" {
filename = "${data.archive_file.lambda_zip.output_path}"
function_name = "my-function"
role = "${aws_iam_role.lambda_role.arn}"
handler = "function.handler"
runtime = "python3.7"
}
When I run this, though, I get the error message data.archive_file.lambda_zip: data.archive_file.lambda_zip: error archiving directory: could not archive missing directory: ../../function_source/
I have tried using absolute paths without success (which wouldn't be a good solution anyway). I have also tried creating the .zip file manually and hardcoding its directly in Lambda declaration, but it only works if I put the .zip file in my terraform directory. It seems Terraform can only see files in its own directory or below, but I'd rather not co-mingle my source files there. Is there a way to do this?
I am using Terraform v0.12.4

How to get filepath of a file in Azure Service Fabric

I have a project which is in an Azure Service Fabric Solution. How can I get specific full filepath of a content file? The content file is in the same folder with my source code.
What I tried:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location
But it turns out:
C:\SfDevCluster\Data_App_Node_4\ABCXYZType_App126\ABCXYZPkg.Code.1.0.0\ABCXYZ.dll
This is a file in bin/debug folder
To get the location of content files you can use:
var path = Path.Combine(
FabricRuntime.GetActivationContext().GetCodePackageObject("Code").Path,
"Readme.txt");
ServiceEventSource.Current.ServiceMessage(this.Context, File.ReadAllText(path));
provided that the file Readme.txt has the Build Action is set to "Content" and the Copy to Output Directory setting is set to something else than "do not copy".

Access files from project folder in UWP

in my solution I have backgroundtask project which has a "Resources" directory. How can I acess the files of this directory?
I already tried
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
and I get a "ResourceMap Not Found" error.
Windows::ApplicationModel::Package^ package = Windows::ApplicationModel::Package::Current;
Windows::Storage::StorageFolder^ installedLocation = package->InstalledLocation;
this should return the Folder of your project that contains your "Resources" folder.

Resources