I have a JS project that uses aws services as a backend (Cognito, AppSync, S3, etc).
I use AWS Amplify to access these services but do not use the amplify CLI; all aws services are configuredd manually.
Regarding AppSync, I have a little script that reads the schema (downloaded manually from the appsync console) and then generates Typescript operations and operation types files (using amplify-graphql-docs-generator and amplify-graphql-types-generator).
Is it possible to do the same for models, ie generate a models file in typescript based on a local schema file ? Or in other words how can I replicate amplify codegen models inside a project that was not setup with the amplify-cli ?
You can probably check the implementation of the amplify codegen and find its inner workings
https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-codegen
Or if you don't mind using the Amplify CLI, you can hook up an existing AppSync project running the following commands in sequence at the project root:
amplify init
amplify add codegen --apiId xxxx
amplify codegen
Related
I'm trying to setup multiple environments for my Vue / Firebase Project.
I have two Firebase Projects
1.) Dev
2.) Prod
The project utilizes Stripe Extension which pulls the API Key from an auto-generated file called:
firestore-stripe-payments.env
which contains:
STRIPE_API_KEY=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_API_KEY-xxxx/versions/latest
Where xxxx is a random 4 character string.
That line pulls the value of the key from Google Secret Manager.
Let's say Dev is 'dddd'
and Prod is: 'pppp'
The issue is that I can only define either:
firestore-stripe-payments-STRIPE_API_KEY-dddd
or
firestore-stripe-payments-STRIPE_API_KEY-pppp
At first I tried to create a new value within Google Secret Manager simply called:
firestore-stripe-payments-STRIPE_API_KEY
The thought was this should be a simple fix, and it would pull the associated API_KEY for the project currently being used.
but this causes the error:
Error: firestore-stripe-payments: Found 'projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY/versions/latest' for secret param STRIPE_API_KEY, but this instance was previously using a different secret projects/fooo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.
Changing secrets is not supported. If you want to change the value of this secret, use a new version of projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.You can create a new version at https://console.cloud.google.com/security/secret-manager?project=fooo
Also, if there is a better place to ask this question please let me know, couldn't find the 'right' room
For this scenario, could you include a separate env (env.dev) file using the following guidelines
.env # loaded in all cases
.env.local # loaded in all cases, ignored by git
.env.[mode] # only loaded in specified mode
.env.[mode].local
For generating separate keys for each environment, I believe from your example you are using a single Stripe Extension on a single project.
Firebase Extensions can support multiple instances of an Extension per project, this will create a separate "dev" secret for you to use.
Additionally, a separate Firebase project with another "Stripe Extension" installation would be recommended to separate any concerns in development.
Most of our client projects have a very similar starting point:
Pristine AWS account used only for a single environment for this application
GraphQL API and a basic model to start with
A REST API with an OAuth handler endpoint and a generic webhook listener endpoint, each with a corresponding Lambda function (with code for each)
I've created this basic amplify app and I want to create a repo with this general structure as a starting point for future projects. The idea being that I'd copy the contents of the repo when starting a project and build from there.
So I've copied the entire amplify directory over to a new location, removing everything that is in the amplify section of the .gitignore file, and I have a folder structure like this:
My steps to start a new project are:
Create a new directory
Copy the template repo files into this directory
run amplify init
Once I do that, it creates two additional files:
amplify/.config/project-config.json
amplify/team-provider-info.json
Then, I try to do amplify push -- but I get No changes detected.
I'm not even sure if what I'm doing is possible -- I was wondering if anyone else has tried this?
I have a single .NET Core .proj file and a single Google Cloud project. The .NET Core project is very simple with a single class implementing IHttpFunction and implementing HandleAsync which is the entrypoint. I have a Cloud Build trigger connected to this project's Git repository which is set to run whenever a commit is pushed into main.
I would like to have more functions-- and hoping to not duplicate common functionality between them -- add those functions to the same project. But when I have multiple classes implementing IHttpFunction, Cloud Build fails.
I think there are at least 2 other ways to do this:
Deploy manually and select a function - but can I do this with Cloud Build triggers too?
Have all functions go through a single "dispatcher" endpoint - which seems messy
What's a good way to do this?
we have a project repo where backend team have added new apis.
other developers have run and configured amplify and codegen.
now I want to add these new queries and their types.
when I run amplify codegen i get this error:
Please download the schema.graphql or schema.json and place in C:\leag\nevClon\newwebsite before adding codegen when not in an amplify project
and when i run amplify add codegen it says Codegen support only one GraphQL API per project.
could someone guide me whats the right way to do that.
I've seen this problem in the past. Things I've tried include ...
Make sure you are in the correct amplify environment.
Run amplify pull to ensure you are up to date.
Try re-initializing using amplify init
When all else fails, try re-cloning the repository.
I have created and published API's using API manager 2.6.0 now I need to push these changes to another environment like system & UAT testing environment.
Can someone help me on how I can configure any repository to push the APIs created using API manager and move from one environment to another. I checked few sites related to WSO2 migration and CI/CD implementation but I could not able to do that properly so I am looking for high level explanation to use repository and migration to different environments.
You can export and import APIs from different environments using the migration APIs or the CLI tool:
Export API as seen here: https://docs.wso2.com/display/AM210/Migrating+the+APIs+to+a+Different+Environment
Export CLI as seen here:
https://docs.wso2.com/display/AM260/Migrating+the+APIs+to+a+Different+Environment
The exported APIs are a set of json and xml files that can be templated, and unless your APIs endpoints in other environments are the same as your development one, you will have to modify the exported APIs jsons and xmls to fit the other enviroment's data.
The best way to set up a repository, will be then to:
Export from your development environment the API to a local machine
Create a template out of it to be used with your favorite template deployment engine
Upload this templates to a repository manager (nexus, artifactory...)
Write the script to fill the template for each environment,
Create another script to call the APIM import CLI or API to import the filled template to each enviroment.
This is all best done within some CI/CD pipeline.