This is my config.yml file. In fact user_id, api_key and shared_secret are the same for each environment (development, test or production).
development:
user_id: '1234'
api_key: '1234'
shared_secret: '43243'
some_dev_data: 'fdsfdsfd'
test:
some_test_data: 'rytr'
production:
some_prod_data: 'hgf'
How do I make them independent from current environment? Or how to share them between all environments?
You can use anchors to pull out shared data:
shared_stuff: &shared
user_id: '1234'
api_key: '1234'
shared_secret: '43243'
development:
<<: *shared
some_dev_data: 'fdsfdsfd'
test:
<<: *shared
some_test_data: 'rytr'
production:
<<: *shared
some_prod_data: 'hgf'
Your values under shared_stuff are given the anchor name shared which you can then pull into your different environments.
Related
I deployed a Nuxt 3 website as a classic SPA since I don't need SSR for my project. Used nuxt generate and deployed the contents from .output/public/ in Azure static web app. It is successfully running now, but when I'm accessing pages with dynamic routes like user/[id] and hit refresh the page, I'm getting this message:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
nuxt.config.ts
export default defineNuxtConfig({
ssr: false,
});
I'm just really new on Nuxt and in Vue world will appreciate any help guys.
I have followed the MSDoc and able to run the Nuxt JS app without any issues.
Make sure you have followed the same steps as below.
Navigate to the GitHub and create a new repository from nuxt-3-starter.
New repo with code will be generated.
In Azure Portal, create a new Static Web App.
Select the GitHub and provide the Repository and branch details as shown below.
We can also check the Workflow file.
My Workflow:
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout#v2
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy#v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0E617661E }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server"
output_location: ".output/public" # Built app content directory
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy#v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0E617661E }}
action: "close"
Make sure the build and deployment are successful. We can check it in GitHub Repository => Actions.
Click on the Workflow file, you can see the Jobs Status.
OutPut:
With dynamic routes - user/[id]
Please Check the code in my GitHub Repository.
I have a deployment that is deploying based on the stage sls deploy --stage staging and I want to export the lambda ARN from that staging function within the Outputs. I expected it to understand the Condition but it seems it doesn't and is trying to deploy to each environment regardless of the Condition.
Is there a way to do it?
service: test
frameworkVersion: '^2.2.0'
plugins:
...
provider:
name: aws
runtime: python3.8
stage: ${opt:stage}
resources:
Conditions:
IsStaging:
Fn::Equals:
- ${self:provider.stage}
- staging
Resources:
...
Outputs:
MyLambdaFunction:
Condition: IsStaging
Value: !GetAtt [ MyLambdaFunction, Arn ]
Export:
Name: MyLambdaFunction
I couldn't find a plugin that mention the Conditional Output, is it something that works in a more up to date framework version or is it just not working?
I tried to have the server address injected to the test with environment variable ABSOLUTE_URL so PhpBrowser would test against it. The config I wanted to do is something like this:
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: "%ABSOLUTE_URL%"
But I simply could not get it to work. Is there anyway I can do it?
Add params section to codeception.yaml file:
params:
- env
Documented at https://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Parameters
I'm trying to write some acceptance tests for laravel 4 with codeception and the selenium module.
I got two problems with that.
The first one is that my app is running
in the homestead vagrant vm and the selenium server is running on the
host machine. So is there a easy way to run the selenium server in the vm and the call the browser o n the host machine ?
My second problem is that when testing the actual live database is used, because the environment of the laravel app is not set to testing. Obviously i would like to have it to use the test database and reset it after each test.
codeception.yaml
actor: Tester
paths:
tests: app/tests
log: app/tests/_output
data: app/tests/_data
helpers: app/tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
suite_class: \PHPUnit_Framework_TestSuite
modules:
config:
Db:
dsn: 'sqlite:app/tests/_data/testdb.sqlite'
user: ''
password: ''
dump: app/tests/_data/dump.sql
acceptance.yaml
class_name: AcceptanceTester
modules:
enabled: [WebDriver,AcceptanceHelper]
config:
WebDriver:
url: 'http://app.dev'
browser: firefox
window_size: 1920x1024
wait: 10
The easy way to run acceptance tests in the vm is to use phantom js in ghostdriver mode. There is a tutorial here:
https://gist.github.com/antonioribeiro/96ce9675e5660c317bcc
You can still see screenshots and the rendered html when tests fail, so it isn't a big deal that you can't see the browser.
For your second question, I prefer to keep a separate tests installation with it's own database. That way changes you make in dev don't alter your test results and it's a better approximation of production.
If you want to use the same installation, you can automate switching out your settings with .env files.
http://laravel.com/docs/4.2/configuration#protecting-sensitive-configuration
your config would look like this:
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_NAME'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
and your .env.php would look like:
return array( 'DB_HOST' => 'hostname', 'DB_NAME' => '' ..etc
than you can use a task runner like robo to automatically update your .env file and run codeception tests.
http://robo.li/
$this->replaceInFile('.env.php')
->from('production_db_name')
->to('test_db_name')
->run();
$this->taskCodecept()->suite('acceptance')->run();
.env files are changing in Laravel 5, but this workflow still works with minimal modification.
http://mattstauffer.co/blog/laravel-5.0-environment-detection-and-environment-variables
What is the best practice for storing/retrieving API keys in rails3?
Should I create my own application yaml and access it through there? If so, how?
Sorry for the noob question...
I use the settingslogic plugin for things like this. Very easy to use.
Add settingslogic to your Gemfile and bundle install:
gem 'settingslogic'
Create a directory for your settings and place the settingslogic yaml in there:
/my_app/config/settings/my_settings.yml
You can include default settings and per environment settings. The file looks like this:
defaults: &defaults
api_key: abc123
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
Add this file: app/models/my_settings.rb, start up your app and you are good to go
class MySettings < Settingslogic
source "#{Rails.root}/config/settings/my_settings.yml"
namespace Rails.env
end
Now you can use call these settings from anywhere in the app like so:
MySettings.api_key