Imagine creating a website with static javascript assets hosted on S3.
Assume further that the JS would need access to values reserved within CDK the cdk stack such as ARN's of other resources dynamically created from CDK.
What would be the best way to resolve that information, and perhaps package it on a settings file for deployment to some s3 path that the website can load?
You can define fixed name for exportValue, in your case the ARN of the resource, with CfnOutput in your cdk
You can retrieve this value with the List-Exports function of the cloudformation sdk
If you want to, deploy your resources through cdk, create the settings file from the outputs of the cdk (using lambda or codebuild to create file to s3 for example) and deploy a static website (Also cdk) in one pipeline. I would suggest you looking in to CDK Pipelines
Related
I have created a new C# Azure Function (EventHub trigger) and added my own logic to handle the events that come in. My issue is that I am not sure how to deploy this new app via terraform. I have created a azurerm_function_app_function resource, and from reading the terraform docs I can see that I can add a file (https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app_function#file) however, for a CSharp project, that's not using csx, I don't see how this can be used.
Is there a way to deploy a C# application using terraform, or should I split these components up, and have terraform create the azurerm_function_app_function and then have a pipeline that uploads my code to the function?
I want to save and use the allure report from amazon S3 (not in-home workspace), so used S3 publisher plugin
target/allure-results and allure-report folders with files were published into amazon S3, but I can't take allure form S3
How I can do that?
If you really want to enable public access to your Allure reports from within S3, you can follow the official guide. In this case, a custom domain name is used. However, you can do the same w/o it just by enabling website hosting and relaxing bucket restrictions.
Note that it's not a secured way to access your reports, as they become visible to the outside world. Even if you use a CloudFront to restrict access to your bucket, it won't solve the visibility problem. It's a critical security issue, as you usually expose different URLs and credentials in test reports.
On one of my projects, there was a GitLab, and we created a simple html page with links to build logs and Allure / Swagger coverage reports. This page was registered to a customer's subdomain and accessible by authorized GitLab users only. Everything else (results aggregation, report generation, copying history, etc.) was handled from within GitLab pipeline.
I'd recommend talking to your DevOps and explain what you are trying to achieve considering all the security concerns. It's basically a one-day job for them.
I cannot find any good examples on how to work with AWS CDK ServiceCatalog resources. My goal is to launch an existing ServiceCatalog product defined by my organization and supply its input parameters using the CDK.
Is it possible? Or is this only to define and change ServiceCatalog products itself, without an option to launch them?
Yes, it is possible to launch the ServiceCatalog product via AWS CDK. The CfnCloudFormationProvisionedProduct construct should be used for this.
CfnCloudFormationProvisionedProduct.Builder
.create(this,"test")
.provisionedProductName("s3")
.productName("s3")
.provisioningArtifactName("1.0")
.provisioningParameters(Arrays.asList(params))
.build()
;
And the params in the code snippet above can be defined as following:
CfnCloudFormationProvisionedProduct.ProvisioningParameterProperty
.builder().key("parameter id").value("parameter value").build()
Use an AWS CloudFormation Parameter section of AWS CDK mentions how to customize your AWS CloudFormation templates. It refers to CloudFormation template. I would like to add parameters to my CDK stack and get the parameters section of the synthesized CloudFormation template.
Do I understand correctly that documentation suggests adding parameters section to synthesized template? If yes, it will be overwritten with every run of cdk synth.
Any other way to define the parameters section?
Edit: Here is a typescript example that reads a bucket name from the context: https://github.com/cloudshiftstrategies/aws-cdk-examples/tree/master/context-example-typescript-app
You can add parameters to the CDK using the CfnParameter type like so:
new cdk.CfnParameter(this, 'MyParameter', {
type: 'String',
default: 'Blah',
noEcho: true,
});
But that is generally discourages by the CDK. The design is to have fully deployable stacks and use code/config as the conditions for what should be created for a given account. This is from their documentation:
When you run the cdk synth command for an app with multiple stacks, the cloud assembly includes a separate template for each stack instance. Even if the two stacks are instances of the same class, the AWS CDK emits them as two individual templates.
You can synthesize each template by specifying the stack name in the cdk synth command. The following example synthesizes the template for stack1.
This approach is conceptually different from how AWS CloudFormation templates are normally used, where a template can be deployed multiple times and parameterized through AWS CloudFormation parameters. Although AWS CloudFormation parameters can be defined in the AWS CDK, they are generally discouraged because AWS CloudFormation parameters are resolved only during deployment. This means that you cannot determine their value in your code. For example, to conditionally include a resource in your app based on the value of a parameter, you must set up an AWS CloudFormation condition and tag the resource with this condition. Because the AWS CDK takes an approach where concrete templates are resolved at synthesis time, you can use an if statement to check the value to determine whether a resource should be defined or some behavior should be applied.
Parameters in the cdk would be done through context values either from the command line or via the cdk.json as documented here: https://docs.aws.amazon.com/cdk/latest/guide/get_context_var.html
This is the recommended way.
cdk deploy MyStack --parameters uploadBucketName=UpBucket --parameters downloadBucketName=DownBucket
I know it's not exactly your question but posting here for reference.
Source: https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-deploy
I am creating files with a custom version number during the build that I want to be publicly available through http.
Assuming I am building the project "MyTestApp", I want the version number text file I created to be available at a location like http://jenkins.company/job/MyTestApp/revision.txt
Any idea how to achieve this?
David, this depends on what you mean by "publicly available". If your Jenkins instance is secured (jenkins.company/configureSecurity/), then access to artifacts requires that your http session be authenticated. If all users who need access have accounts on the Jenkins server, then you just need to use the post-build action "archive the artifacts", and your text file would be available here:
jenkins.company/job/MyTestApp/jobnumber/artifact/revision.txt
Or here:
jenkins.company/job/MyTestApp/lastSuccessfulBuild/artifact/revision.txt
See this screenshot: http://note.io/17oiykI
If you need unauthenticated access, you could publish your artifacts to another web server on the same or a different host. Or you could upload them to an Amazon S3 bucket.