Add replicationRegions to an imported DynamoDB table via CDK? - amazon-dynamodb

I have a dynamodb table that was created via console and I want to enable multi-region support by adding to the list of replicationRegions using CDK.
After importing the original table using:
const table = Table.fromTableArn(this, "ImportedTable", "arn:aws:dynamodb...");
I realized I did not have access to the tables replicationRegions field as I would when creating new one.
Is there a way add to the list of replicationRegions on an imported dynamodb table using CDK?

Yes, but use cdk import instead of Table.fromTableArn.
The fromSomethingArn-type methods create *read-only* references to an external resource.* You can't use these to modify a resource. The ISomething interface constructs these methods return are useful for things like creating new permissions and targets.
The cdk import command is preview functionality to properly import existing resources into a CDK stack. A DynamoDB Table is a resource type that supports import operations. Once this one-time import completes, the "adopting" CDK stack can modify the "imported" table like any other, say, by adding replication regions.
In other words, The CDK can only modify resources it owns. To make ad-hoc modifications to an existing resource without permanently "adopting" it, use the SDKs instead.
* Earlier versions of the CDK docs did call these from... methods "importing" operations, but have been updated to use the less ambiguous term "referencing".

Related

How to make AWS Api Gateway deployment depend on dynamic list using Terraform

When I generate resources, methods etc. using "for_each", how can I make a deployment depend on them? Terraform requires a static list as value for "depends_on"
I think what you are looking for here is this (somewhat hidden) reference in terraform documents about triggers
I was facing the same issue (using for_each to create gateway methods, integrations) but was not able to reliably trigger api-gateway redeployment, until this...
... or removing the .id references to calculate a hash against whole resources. Be aware that using whole resources will show a difference after the initial implementation. It will stabilize to only change when resources change afterwards
This allow us to do the following in triggers
triggers = {
redeployment = sha1(jsonencode([
aws_api_gateway_resource.gateway_resources,
aws_api_gateway_method.gateway_methods,
aws_api_gateway_integration.gateway_integrations,
]))}
By removing .id (and thus not needing to reference each.key, or any element in the dynamic list) you let terraform decide if the hash of the file changed. If it did it will redeploy, if it doesnt change, then no redeploy required :)
Reference https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_deployment#terraform-resources
Look at the comments on 'triggers'

What is purpose of FDPhysSQLiteDriverLink?

When use FDPhysSQLiteDriverLink in SQLite? Is it necessary and how set up in delphi.
My Sqlite work without FDPhysSQLiteDriverLink.
As I recall, I needed that for certain advanced features in some other SQLite components.
Security (TFDSQLiteSecurity). The class allowing you to manage a SQLite database encryption/passwords. It requires you use FDPhysSQLiteDriverLink.
Database Validation (TFDSQLiteValidate). This component allows you to access the SQLite Validation Service to perform Sweep, Vacuum, for example. It requires you to use FDPhysSQLiteDriverLink.
Backup (TFDSQLiteBackup). This component allows you to perform database backup/restore/copy operations. It requires you to use FDPhysSQLiteDriverLink.
As for setting it up, I did nothing other than add the component to my project and then point the other components mentioned above to it. I left DriverID blank.

How do you manage adding new attributes on existing objects when using firebase?

I have an app using React + Redux and coupled with Firebase for the backend.
Often times, I will want to add some new attributes to existing objects.
When doing so, existing objects won't get the attribute until they're modified with the new version of the app that handles those new attributes.
For example, let's say I have a /categories/ node, in there I've got objects such as this :
{
name: "Medical"
}
Now let's say I want to add an icon field with a default of "
Is it possible to update all categories at once so that field always exists with the default value?
Or do you handle this in the client code?
Right now I'm always testing the values to see if they're here or not, but it doesn't seem like a very good way to go about it. I'd like to have one place to define defaults.
It seems like having classes for each object type would be interesting but I'm not sure how to go about this in Redux.
Do you just use the reducer to turn all categories into class instances when you fetch them for example? I'm worried this would be heavy performance wise.
Any write operation to the Firebase Database requires that you know the exact path to the node that you're writing.
There is no built-in operation to bulk update nodes with a path that is only partially known.
You can either keep your client-side code robust enough to handle the missing properties, or you can indeed run a migration script to add the new property to each relevant node. But since that script will have to know the exact path of each node to write, it will likely first have to read/query the database to determine those paths. Depending on the number of items to update, it could possibly use multi-location updates after that to update multiple nodes in one call. E.g.
firebase.database().ref("categories").update({
"idOfMedicalCategory/icon": "newIconForMedical",
"idOfCommercialCategory/icon": "newIconForCommercial"
"idOfTechCategory/icon": "newIconForTech"
})

How to import a Json arrays without overwriting existing objects in the FireBase RealTimeDB

I import a large amount of JSON files to my FireBase DB console with this feature:
https://github.com/firebase/firebase-import
It works well when I upload arrays with lots of objects,
but if i want to upload a new array object to existing table, it overrides the existing object instead of adding the new one.
I would be happy to find a right way to "Update" the new objects to the existing table with firebase-import or any other tool.
As pointed out by Jen, you can use the Firebase CLI to update objects in your database. Just use this command:
firebase database:update /path/to/object -d newArray.json
where:
/path/to/object - the path of the object that you want to update.
newArray.json - the json file containing the array with the new values.

Passing value between two components in angular2-meteor project

I am using angular2-meteor.
When I try to pass a value between two components (when the value change in the first component, create an event in second component and use this new value), I have two ways right now:
One way is meteor way: using this.autorun and Session.get.
Another way is angular2 way: using Injectable service with EventEmitter.
Which way should be prior? Or is there any other better way? Thanks
Now I used angular2-meteor a while.
Although the angular2-meteor tutorial has no example so far about using or choosing Angular 2 service or Meteor Session.
But I feel angular 2 takes the lead in the front end, while meteor makes reactivity easier and also handle all back end things.
So I went with angular2 way using service to share between components. And service is very powerful like #todd-w-crone said.
If anyone has better answer, I will switch to accept that one.
I find it practical to create a new service called App.states.ts which is accessed globally and mimics Session (get / set).
I commonly import this service to all necessary components to get or set new value such as User.status, company.profile, lastProduct, etc.
Since this service is #injectable it can also make use of other services, in case a value hasn't been set already.
This allows me to ask for a variable in a component appState.getLastModifiedItem(), then in app.states.ts I'll write this function to pass this.modifiedItem or either:
Request another service item.service.ts to fetch data
Call another function with itemCollection.findOne({...}) and return such value.
You can configure Mongo queries as you want and either store static data in appState or keep subscription items in appState.
Do take into consideration that all subscriptions handled by an #injectable within a component are imported by such component. Be wary of conflicting subscriptions between components/services.

Resources