My Terraform directory structure looks something like :
├── deploy
│ ├── dev.tfvars
│ └── qa.tfvars
├── modules
│ ├── private
│ │ ├── bastion.tf
│ ├── db.tf
│ │ └── variables.tf
│ └── public
│ ├── web.tf
│ └── variables.tf
├── main.tf
In bastion.tf, I am trying to call a variable from variables.tf like this :
resource "aws_eip" "bastion" {
instance = "var.eip"
vpc = true
}
where, eip = 10.x.x.x is set in say, dev.tfvars.
And the configuration for main.tf looks like :
provider "aws" {}
terraform {
backend "s3" {}
}
module "private" {
source = "./modules/private"
}
While running terraform validate, it gives me an error that - The argument "eip" is required, but no definition was found. Even if I try giving eip to module like :
module "private" {
source = "./modules/private"
eip = var.eip
}
it gives me another error :
An input variable with the name "eip" has not been declared.
This variable can be declared with a variable "eip" {} block
I have variable "eip" {} already defined in my variables.tf such that it takes the values from .tfvars file, but somehow it isn't. Can anyone suggest what else could I be missing?
Sounds like you are missing variables declarations...
From your file structure:
├── deploy
│ ├── dev.tfvars
│ └── qa.tfvars
├── modules
│ ├── private
│ │ ├── bastion.tf
│ ├── db.tf
│ │ └── variables.tf
│ └── public
│ ├── web.tf
│ └── variables.tf
├── main.tf
There does not seem to be a companion variables.tf for the main.tf each level needs to declare the variables that will be used by resources or submodules.
If you upload your code to GitHub and post a link I could help to get you unblocked.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have a project which is written 3 years ago in reactjs 15 version and also it is single tier architecture project. I am right now converting it to 3 tier project architecture. So I thought of having the react part alone. My question is how should I create a reactJS folder structure using the new create-react-app and add the already existing code into it. I know this question might be broad. But any steps will help me to better understand the structure to be followed in react. Its been like only 2 months I am learning reactjs.
"react": "^15.6.1",
"react-csv": "^1.0.8",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^15.6.1",
"react-dropzone": "^4.2.3",
"react-flipcard": "^0.2.1",
"react-notification-system": "^0.2.16",
"react-pdf": "^2.4.2",
"react-router": "^3.0.0",
"react-router-dom": "^4.2.2",
"react-stars": "^2.2.5",
"react-table": "^6.7.4",
"react-tabs-navigation": "^0.4.4",
"react-toastr": "^2.8.2",
"semantic-ui-react": "^0.63.5",
"superagent": "^3.8.1",
"universal-cookie": "^2.1.0",
"url-loader": "^4.1.0",
"x-frame-options": "^1.0.0"
I would recommend you to make components folder in src folder. There you can structure components to atoms, molecules, organisms, templates and pages if you are a fan of a Atomic design as I am. From there every component should be separated in separate folder and have component.types.js/ts, component.constants.js/ts, component.scss, component.js/tsx. Types would refer to prop and any other types related to that component. Constants, components and scss file are quite obvious as for what they are used. Also you can have test folder in every component where you can write tests.
Also you can have common folder in src where you can put your utility files, for example custom hooks, http setup etc.
Another important folder in src is config. All config your app needs can be in there in different files if that is needed.
Last but not the least is assests foloder inside src. As name suggests you put all of your static assets (fonts, images, videos...).
I think this is very good basis to start from and expand your folder structure as you see fit and as project is needed. Also none of this i strict to naming but those are some conventions that you can read here.
awesome-app
├── src
│ ├── components
│ │ ├── atoms
│ │ │ ├── button
│ │ │ │ ├── button.types.ts
│ │ │ │ ├── button.component.tsx
│ │ │ │ ├── button.constants.ts
│ │ │ │ ├── button.scss
│ │ │ │ ├── test
│ │ │ │ ├── button.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── molecules
│ │ │ ├── action-card
│ │ │ │ ├── action-card.types.ts
│ │ │ │ ├── action-card.component.tsx
│ │ │ │ ├── action-card.constants.ts
│ │ │ │ ├── action-card.scss
│ │ │ │ ├── test
│ │ │ │ ├── action-card.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── organisms
│ │ │ ├── school-module-row
│ │ │ │ ├── school-module-row.types.ts
│ │ │ │ ├── school-module-row.component.tsx
│ │ │ │ ├── school-module-row.constants.ts
│ │ │ │ ├── school-module-row.scss
│ │ │ │ ├── test
│ │ │ │ ├── school-module-row.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── pages
│ │ │ ├── users-page
│ │ │ │ ├── users-page.types.ts
│ │ │ │ ├── users-page.component.tsx
│ │ │ │ ├── users-page.constants.ts
│ │ │ │ ├── users-page.scss
│ │ │ │ ├── test
│ │ │ │ ├── users-page.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ ├── styles
│ │ ├── base
│ │ │ ├── _base.scss
│ │ │ ├── _font.scss
│ │ │ └── ...
│ │ └── ...
│ │
│ ├── assets
│ │ ├── fonts
│ │ │ └── ...
│ │ ├── images
│ │ │ └── ...
│ │ └── ...
│ ├── config
│ │ └── ...
│ └── redux
└── actions
└── ...
I have this directory structure
├── components
│ ├── quarks
│ │ └── index.js
│ │ └── ...
│ ├── bosons
│ │ └── index.js
│ │ └── GridLayout.vue
│ │ └── ...
│ ├── atoms
│ │ └── ButtonStyle.vue
│ │ └── InputStyle.vue
│ │ └── index.js
│ │ └── ...
│ ├── .......
└─────
I'd like to ignore the index.js within each folder, but I'm not getting it, I've tried it in several ways
const path = require('path')
const chokidar = require('chokidar')
const ROOT_PATH = path.resolve('components')
const watcher = chokidar.watch(ROOT_PATH, {
ignored: ROOT_PATH + '/*/index.js', //does not work
ignoreInitial: true
})
already tried:
'./components/**/index.js',
'./components/*/index.js',
'components/*/index.js',
'components/**/index.js',
'ROOT_PATH + '/**/index.js'
Anyone have any idea how to make it work?
The chokidar documentation specifies that the ignored parameter is anymatch-compatiable so this could be completed in many ways.
Here is a regular expression solution...
Any index.js file, even in the root folder:
{
ignored: /(^|[\/\\])index\.js$/,
// ...
}
Only index.js file in a sub-folder:
{
ignored: /[\/\\]index\.js$/,
// ...
}
Also note in your example you use signoreInitial this is not an option, perhaps you meant ignoreInitial?
Alternatively with callback:
{
ignored: (path) => { return path.endsWith('\\index.js') || path.endsWith('/index.js'); },
// ...
}
Chokidar seems bugged, defective to ignore files on MacOS, that's the impression I have.
So before running my action, I'm checking to see if the file is the same one I want to ignore.
chokidar
.watch('components', { ignoreInitial: true })
.on('all', (event, filename) => {
filename !== 'index.js'
// action here
})
What worked for me on Mac was using **:
ignored: ['**/node_modules'],
So if the other options don't work because of bugs, go for this one:
ignored: ['**/index.js'],
I am attempting to add a GUI to a small project of mine using Conrod. I have managed to work my way down to 3 compilation errors:
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:53
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:87
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:106:24
|
106 | glium::glutin::ControlFlow::Break
| ^^^^^^ Could not find `glutin` in `glium`
I've studied the examples that ship with Conrod (particularly the text_edit.rs example) and have successfully compiled and run them. As far as I can tell, they use the same techniques (as my code is directly inspired by their examples), yet does not suffer from the unresolved imports of glutin.
Furthermore, I cannot seem to find any reference to glutin in the project directory itself:
$> pwd
~/dev/conrod/src
$> tree.
.
├── backend
│ ├── gfx.rs
│ ├── glium.rs
│ ├── mod.rs
│ ├── piston
│ │ ├── draw.rs
│ │ ├── event.rs
│ │ └── mod.rs
│ └── winit.rs
├── border.rs
├── color.rs
├── cursor.rs
├── event.rs
├── graph
│ ├── algo.rs
│ ├── depth_order.rs
│ └── mod.rs
├── guide
│ ├── chapter_1.rs
│ ├── chapter_2.rs
│ └── mod.rs
├── image.rs
├── input
│ ├── global.rs
│ ├── mod.rs
│ ├── state.rs
│ └── widget.rs
├── label.rs
├── lib.rs
├── position
│ ├── matrix.rs
│ ├── mod.rs
│ ├── range.rs
│ └── rect.rs
├── render.rs
├── tests
│ ├── global_input.rs
│ ├── mod.rs
│ ├── ui.rs
│ └── widget_input.rs
├── text.rs
├── theme.rs
├── ui.rs
├── utils.rs
└── widget
├── bordered_rectangle.rs
├── builder.rs
├── button.rs
├── canvas.rs
├── collapsible_area.rs
├── drop_down_list.rs
├── envelope_editor.rs
├── file_navigator
│ ├── directory_view.rs
│ └── mod.rs
├── graph
│ ├── mod.rs
│ └── node.rs
├── grid.rs
├── id.rs
├── list.rs
├── list_select.rs
├── matrix.rs
├── mod.rs
├── number_dialer.rs
├── plot_path.rs
├── primitive
│ ├── image.rs
│ ├── line.rs
│ ├── mod.rs
│ ├── point_path.rs
│ ├── shape
│ │ ├── circle.rs
│ │ ├── mod.rs
│ │ ├── oval.rs
│ │ ├── polygon.rs
│ │ ├── rectangle.rs
│ │ └── triangles.rs
│ └── text.rs
├── range_slider.rs
├── rounded_rectangle.rs
├── scrollbar.rs
├── scroll.rs
├── slider.rs
├── tabs.rs
├── text_box.rs
├── text_edit.rs
├── title_bar.rs
├── toggle.rs
└── xy_pad.rs
For reference, my Cargo.toml also includes glutin as a dependency:
[features]
default = ["winit", "glium"]
winit = ["conrod/winit"]
glium = ["conrod/glium"]
[dependencies]
conrod = "^0.57"
find_folder = "*"
glutin = "*"
I believe this is a misconception about the module structure of conrod and glium.
The conrod crate has a number of backend modules, containing utility functions for each of the different backends. conrod::backend::glium is this module for glium, and it contains structures and things useful for using conrod with glium.
In your case, however, I think you mistook this module for glium itself.
glium is a separate crate from conrod, and you'll need to depend on it much like you depend on glutin. glium does indeed have a glium::conrod property, so if you do pull it in with extern crate glium; rather than using conrod::backend::glium, it should "just work"!
You'll need to add some line glium = 0.x in your Cargo.toml as well, but that should be trivial.
I have seen all the posts pointing to various guides purporting to get ABS working with IntelliJ (Android Studio), including here, and here.
For the most recent version of ABS and AS, they don't work.
Generally, the tutorial doesn't match the IDE. Getting past that, and assuming that doing an 'import module' using gradle instead of maven is allowed, I eventually get:
Plugin with id 'android-library' not found
Does anyone have a tutorial for getting the latest version of ABS working with the latest version of AS?
Fwiw, I tried going the Eclipse route with the intention of exporting and then trying to bring it into AS (this is definitely not my preferred path), but I ended-up getting a bunch of "Unable to execute dex: Multiple dex files define..." errors surrounding Jackson.
If it's useful, here is my build.gradle, but my preferred solution would use more "standard" mechanisms than mucking with that and would also, then, more likely be useful to others. Here's the file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
And, my project directory structure:
D:.
└───T-n-T
├───.gradle
│ └───1.6
│ └───taskArtifacts
├───.idea
│ ├───copyright
│ ├───libraries
│ └───scopes
├───assets
├───bin
│ ├───classes
│ │ └───com
│ │ └───pha
│ │ └───t-n-t
│ │ ├───models
│ │ └───services
│ └───res
├───build
│ ├───apk
│ ├───assets
│ │ └───debug
│ ├───classes
│ │ └───debug
│ │ └───com
│ │ └───pha
│ │ └───t-n-t
│ │ ├───models
│ │ └───services
│ ├───dependency-cache
│ │ └───debug
│ ├───incremental
│ │ ├───aidl
│ │ │ └───debug
│ │ ├───dex
│ │ │ └───debug
│ │ ├───mergeAssets
│ │ │ └───debug
│ │ └───mergeResources
│ │ └───debug
│ ├───libs
│ ├───manifests
│ │ └───debug
│ ├───res
│ │ ├───all
│ │ │ └───debug
│ │ │ ├───drawable-hdpi
│ │ │ ├───drawable-mdpi
│ │ │ ├───drawable-xhdpi
│ │ │ ├───drawable-xxhdpi
│ │ │ ├───layout
│ │ │ ├───menu
│ │ │ ├───values
│ │ │ ├───values-sw720dp-land
│ │ │ ├───values-v11
│ │ │ ├───values-v14
│ │ │ └───xml
│ │ └───rs
│ │ └───debug
│ ├───source
│ │ ├───aidl
│ │ │ └───debug
│ │ ├───buildConfig
│ │ │ └───debug
│ │ │ └───com
│ │ │ └───pha
│ │ │ └───t-n-t
│ │ ├───r
│ │ │ └───debug
│ │ │ └───com
│ │ │ └───pha
│ │ │ └───t-n-t
│ │ └───rs
│ │ └───debug
│ └───symbols
│ └───debug
├───gen
│ └───com
│ └───pha
│ └───t-n-t
├───gradle
│ └───wrapper
├───libs
├───res
│ ├───drawable-hdpi
│ ├───drawable-ldpi
│ ├───drawable-mdpi
│ ├───drawable-xhdpi
│ ├───drawable-xxhdpi
│ ├───layout
│ ├───menu
│ ├───values
│ ├───values-sw600dp
│ ├───values-sw720dp-land
│ ├───values-v11
│ ├───values-v14
│ └───xml
└───src
└───com
└───pha
└───t-n-t
├───models
└───services
It should be noted that this represents the project after having rolled it back after a failed attempt to get this working.
UPDATE
I don't know if it's progress, but it's different. I have what I think is the library project from ABS sitting with my main project, and added as a module. I think this is the case because in the IDE, in the main project, SherlockActivity seems to be available. I can extend it (sort of) and can import it's namespace (com.actionbarsherlock.app). I say sort of because everything is fine until I try to build, at which point I get:
Gradle: package com.actionbarsherlock.app does not exist
Gradle: cannot find symbol class SherlockActivity
and the build fails. So something is clearly not quite right.
Any suggestions?
SOLVED
Wow. What a pain. What I ultimately ended-up doing:
As described by others
1) Download and extract ABS
2) Save it in its own folder under your primary project (say ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export is checked)
Pulled from other sources
4) Exclude the ActionBarSherlock/target directory (Open Module Settings)
5) If your primary project uses the support library, change that dependency to Provided (Open Module Settings)
Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.
For me the following works fine :
Copy the actionbarsherlock directory to your project root to have
MyAppProject
|-actionbarsherlock
|--build.gradle
|-MyApp
|--build.gradle
|-build.gradle
|-settings.gradle
build.gradle of actionbarsherlock
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
build.gradle of MyApp
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile project(':actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
}
settings.gradle
include ':MyApp', ':actionbarsherlock'
and nothing in the MyAppProject build.gradle
Next Right clik on your MyAppProject > Open Module settings
And on the module section import module and select actionbarsherlock directory. Apply
and to verify re open modul settings, go Modules, click on YourApp and verify if on the dependencies you have actionbarsherlocj on scope compile. if yes, you are ready .
From my update to the question, above:
What I ultimately ended-up doing:
As described by others
1) Download and extract ABS
2) Save it in its own folder under your primary project (say, ActionBarSherlock)
3) Import it as a Module (new: use Maven / pom.xml - make sure Export
is checked)
Pulled from other sources
4) Exclude the ActionBarSherlock/target directory (Open Module
Settings)
5) If your primary project uses the support library, change that
dependency to Provided (Open Module Settings)
Again, I'm not sure why this was so difficult, or if I've done it correctly, or that there aren't any issues yet to be found (I have an empty Activity which extends SherlockActivity, it does build, and I can deploy it to, and run it on, an emulator), but there you go.
UPDATE
This configuration ended up not working. How or why it fell apart, I don't know. But after restarting AS, it fell apart. Following the steps here - again - did, this time, get it working.
This is my configure file:
The layout.jade does not seem to be working. But the jade is working. I used Chrome to check, and am sure that the layout HTML is not loaded into the page.
module.exports = function(app, express, mongoose){
var config=this
app.configure(function (){
app.set('views',__dirname+'/views')
app.set('view engine','jade')
app.set('view options', {layout:true})
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieParser())
app.use(express.session({secret: 'topsecret',store: new express.session.MemoryStore}))
app.use(express.static(app.path.join(app.application_root,"public")))
app.use(express.errorHandler({dumpExceptions:true,showStack:true}))
app.use(express.bodyParser({keepExtensions: true, uploadDir:"./public/uploads"}))
app.use(app.router)
})
/*DB part:*/
app.mongoose.connect('mongodb://localhost/dio_database')
return config
}
The render command:
app.get('/items/:id',function(req,res){
models.ItemModel.findOne({_id:req.params.id}).exec(function(err,item){
if (!err){
res.render('item.jade',item)
} else
return console.log(err)
})
})
My layout.jade, quite simple:
!!!
doctype 5
html
head
title "Dio"
link(rel='icon', href='favicon.ico', type='image/x-icon')
link(rel='shortcut', href='favicon.ico', type='image/x-icon')
link(rel="shortcut", href="favicon.ico", type="image/vnd.microsoft.icon")
link(rel="icon", href="favicon.ico", type="image/vnd.microsoft.icon")
script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js")
script(src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js")
script(src="./javascripts/underscore-min.js")
script(src="./javascripts/backbone-min.js")
link(rel='stylesheet', href='./css/main.css', type="text/css", media="screen")
body
div#topbar Dio--where shitty thing happens
div#main!= body
footer
p
| Node.js MVC template by XXX
And the following is my npm list:
├─┬ bcrypt#0.7.3
│ └── bindings#1.0.0
├─┬ express#3.0.3
│ ├── commander#0.6.1
│ ├─┬ connect#2.7.0
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ └── qs#0.5.1
│ ├── cookie#0.0.5
│ ├── cookie-signature#0.0.1
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── fresh#0.1.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.0
│ └── mime#1.2.6
├── fs#0.0.0
├── imagemagick#0.1.3
├─┬ jade#0.27.7
│ ├── coffee-script#1.4.0
│ ├── commander#0.6.1
│ └── mkdirp#0.3.4
├─┬ mongodb#1.2.2
│ └── bson#0.1.5
├─┬ mongoose#3.4.0
│ ├── hooks#0.2.1
│ ├─┬ mongodb#1.1.11
│ │ └── bson#0.1.5
│ ├── ms#0.1.0
│ └── sliced#0.0.3
├─┬ node-static#0.6.5 extraneous
│ ├── colors#0.6.0-1
│ └─┬ optimist#0.3.5
│ └── wordwrap#0.0.2
└── path#0.4.9
Actually the reason for such problem is quite simple:
Express 3 no longer supports layout..But do not be sad. Actually Express 3 begins to adopt a more natural and easier way, which is called block/extends.
The basic usage should be like this:
// In layout file: layout.jade
html
head
title XXX
block scripts
body
block content
block footer
// in a extended file, for example index.jade:
extends layout
block scripts
//write javascript part
block content
// write content
block footer
// write the footer
It actually becomes easier and more flexible. Glad to get it finally. But it took me more than 2 hours.
I am just wondering why so few people mentioned this change more clearly and openly. Hope this post can help some people like me.