I am trying to create a service catalog product using a cloudformation template with aws-cdk. My template has already been created and stored in s3. Here is the sample code I am using for doing this
template_location = "".join(["https://s3.amazonaws.com/", S3_RESOURCES_BUCKET, "/", "template.json"])
sc.CfnCloudFormationProduct(scope, "SCProduct", name="SCProduct", owner="",
provisioning_artifact_parameters=[{"info": {"loadTemplateFromUrl": template_location}}])
I am receiving this error when I am trying to synthesize:
jsii.errors.JSIIError: No stack could be identified for the construct at path SCProduct
What am I doing wrong here? Any help will be greatly appreciated.
Instead of scope you need to pass the stack object, usually it's self.
Related
In the AWS CDK, it's straight forward to create a Pinpoint Service. But how do you get the Project ID (also referred to as the Pinpoint App ID or Application ID) for use in subsequent CDK code.
Create a Pinpoint project:
const pinpointProject = new pinpoint.CfnApp(this, 'PinpointNotificationProject', {
name: 'myProject',
});
In the AWS CloudFormation docs it says:
"When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the unique identifier (ApplicationId) for the Amazon Pinpoint application."
However, the following CDK code returns the project name not the id. The value of logicalId = myProject.
cdk.Fn.ref(pinpointProject.logicalId); // This returns 'myProject'
pinpointProject.ref; // This also returns 'myProject'
This is confirmed fixed in the latest CDK version 1.130.0. The ref property now returns the Pinpoint ProjectId.
The problem you are running into is that pinpoint is not a finished module. You can see this that all the functions within are prefixed with Cfn - cloudformation. This means that they are barebones and not tied into all the interface hooks that the rest of CDK is making use of to toss things around.
First, the logical ID is NOT the project name. the Logical Id is part of the Cloudformation Template that is generated for any resource Cloudformation is going to stand up. It links the given resource to the stack, so that any changes under the same logical id will be applied to the same stood up resource. It is only referenced internally to the cloudformation stack and never known outside. CDK uses the LogicalID to generate the name of the resource if you do not specify one.
Second, Taking a look at the documentation shows that CfnApp has the following property: attrArn. Meaning in your code, you would reference this by pinpointProject.attrArn - the arn of a pinpoint resource is something like: arn:aws:mobiletargeting:region:accountId:apps/projectId. with, as you guessed it, the projectId as the last value. you can split the string and get that value out, or use the arn manipulation methods provided as part of the core module to extract what you need.
Finally, even though the Pinpoint module is pretty much just barebones, it may still be possible to pass the variable storing your Pinpoint Construct Object to whatever other resource requires it. I say may because, as mentioned, most of the Cfn prefixed functions do not have the proper hooks to do this well - but some do, and Ive never worked with Pinpoint directly.
I recommend spending some time to understand how the CDK Documentation is laid out. Its bare bones in places, but once you understand how they structured it, these kinds of questions are readily answered within.
I need to put a new ES index in place to switch over to at some point in the future. I've been using aliases to do this, by having my app reference an alias, and using the HTTP API to point the alias at either the existing or new index as needed. Unfortunately, when the app gets re-started it complains that the index already exists as an alias. See stacktrace:
org.elasticsearch.indices.InvalidIndexNameException: [redacted] Invalid index name [redacted], already exists as alias
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.validateIndexName(MetaDataCreateIndexService.java:174)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.validate(MetaDataCreateIndexService.java:510)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.access$100(MetaDataCreateIndexService.java:86)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:209)
at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:328)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)
Anyone got any idea why this is happening and how I can prevent it?
This appears to have been fixed, coincidentally, by the release of v0.0.4.0 the plugin today
https://noamt.github.io/elasticsearch-grails-plugin/guide/single.html#history
I am trying to add Angular JS jQuery-File-Upload in my rails application.
To implement this, I am using
https://github.com/tors/jquery-fileupload-rails gem
Angular JS code from http://blueimp.github.io/jQuery-File-Upload/angularjs.html
Now when I tried to add a new file it is showing an error
Uncaught TypeError: Object # has no method 'scope'
Here I am adding screenshot of the response that I got on file uploading.
Can anyone help me to figure out the error?
Your "data" object clearly does not have any method "scope()". That's why the error. Are you trying to set some variable in "data" object to some angular "scope"? In that case double check, because there isn't any scope variable in 'data'. After you set it correctly you can either access it by data.scope, you don't need a method to retrieve it.
I ran into this same issue, and after spending a few hours on it, I can suggest simply copying the sources from the demo page instead of trying to use the sources as they are provided in the download package.
I have the same issue and after a few hours dig into my code, I found the problem was duplicate jquery.fileupload-angular.js files were included in my html page.
Remove the duplicated reference js file solved my problem straight away.
I'm trying to create an ical-file.
So I set Router::parseExtensions('ics') in router.php.
I created a folder ics in app/views/layouts and a default.ctp with this content
<?php
header('Content-Type: text/calendar');
echo $content_for_layout;
?>
In my reservationsController I created a ical() action and created a ical.ctp in /app/views/reservations/ics/.
So, if I'm trying to access http://localhost/reservations/ical/1.ics I get an error:
Error: The view for ReservationsController::ical() was not found.
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\ical.ctp
So I'm a bit confused about the error-message. Why does it search the ical.ctp in app\views\reservations\ and not in app\views\reservations\ics\?
When I'm using another extension like .xml the error message looks like this:
Error: Confirm you have created the file: C:\xampp\htdocs\ers\app\views\reservations\xml\ical.ctp
Why does xml work and ics don't? What went wrong?
I've just finished dealing with this situation myself. I'd been trying to get a csv extension to display, and I was also getting the "missing view" error.
Everything was in place; I had my /app/views/layouts/csv/default.ctp and /app/views/users/csv/export.ctp view files set up. I had Router::parseExtensions('csv'); at the top of my /app/config/routes.php file.
Turns out, what I had forgotten was to add the RequestHandler component to my controller's components array: var $components = array('RequestHandler');.
Once I did that everything worked perfectly.
So if you've stumbled upon this question because you're having the same issue, check to be sure you're loading the RequestHandler component fixes things for you...
I just had the same trouble creating the ics example # http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2
Needed quite a while to figur out that this seems to be a cake bug and opend a ticket for it :)
http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/2565-cakeresponse-is-missing-icalendar-and-not-responding-as-documented
Hopefully this will be resolved soon.
PS: I also posted a workaround / quickfix for this until it is fixed in the core.
I'm trying to figure out how to extract a solution file .wsp file from a SharePoint server. Is this possible and if so how?
You can make a small console application and access the solutions using the SPFarm.Local.Solutions property. Include the Microsoft.SharePoint.Administration namespace and use the following code snippet to download the solution file:
SPSolutionCollection solutions = SPFarm.Local.Solutions;
foreach (SPSolution solution in solutions)
{
SPPersistedFile wspFile = solution.SolutionFile;
wspFile.SaveAs("c:\\Temp\\Solutions\\" + solution.Name);
}
You need to make sure that your output directory exists before calling the SaveAs() method. If it does not exists an exception is thrown.
You can access the Solutions on a farm by using the SPFarm.Local.Solutions property. I'm not sure if you can retrieve the underlying file though. That's where I'd start.